/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{   
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n+1), poss(n+1, 1);
    ll mx = 0;
    for(int i = 1; i <= n; i++)
    {
    	cin >> a[i];
    	if(mx > a[i])
    		poss[i] = 0;
    	mx = max(mx, a[i]);
    }
    for(int i = n; i > 0; i--)
    {
    	if(!poss[i])
    	{
    		for(int j = 0; j < i; j++)
    			poss[j] = 0;
    	}
    }
    ld ns = 1;
    ld res = 0;
    for(int i = 0; i < m; i++)
    {
    	ll r;
    	ld p;
    	cin >> r >> p;
    	if(r == n || poss[r+1])
    	{
    		res += ns * p;
    		ns *= (1 - p);
    	}
    }
    if(poss[1])
    {
    	cout << 1 << '\n';
    	return;
    }
    cout << fixed << setprecision(7) << res << '\n';


    
}  
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int tc = 1;
    cin >> tc;
    while(tc--)
        test_case();
    return 0;
}

