#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++ ) cin >> a[i];
for (int i = 1; i <= n; i++ ) cin >> b[i];
int pos = n;
for( ; pos >= 0; pos--) if(a[pos] != b[pos]) break;
int q;
double ret(1.0);
cin >> q;
while(q--){
int r;
double p;
cin >> r >> p;
if(r >= pos) ret *= 1-p;
}
printf("%.8f\n",1-ret);
return 0;
}

京公网安备 11010502036488号