#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

const int N = 3e5 + 5;

int a[N];
bool is[N];
int mx[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(12);

	int tc = 1;
	cin >> tc;
	while(tc--) {
		int n, q;
		cin >> n >> q;
		for(int i=0; i<n; i++) {
			cin >> a[i];
		}
		a[n] = n+10;
		memset(is, 0, sizeof is);
		is[n] = 1;
		is[n-1] = 1;
		for(int i=n-2; i>=0; i--) {
			if(a[i] <= a[i+1]) is[i] = 1;
			else break;
		}
		mx[0] = a[0];
		for(int i=1; i<n; i++) {
			mx[i] = max(mx[i-1], a[i]);
		}
		int i;
		long double ans = 0, p, pre = 1.0;
		for(int j=0; j<q; j++) {
			cin >> i >> p;
			i--;
			// cout << p << " " << pre << " " << ans << endl;
			if(is[i+1] && mx[i] <= a[i+1]) {
				ans += pre*p;
				pre *= (1-p);
			}
		}
		if(is_sorted(a, a+n)) cout << 1.0 << endl;
		else cout << ans << endl;
	}

	return 0;
}