#include <iostream>   #include <vector>   #include <string>   #include <cstring>   #include <cmath>   #include <climits>   #include <algorithm>   #include <map>   #include <stack>   #include <unordered_map>   #include <set>   #include <unordered_set>   #include <utility>   #include <iomanip>      using namespace std;   typedef long long int ll;   ll pw(ll a, ll b, ll m){    ll ans=1;    while(b>0){     if(b&1) ans=(ans*a)%m;     a=(a*a)%m;     b>>=1;    }    return ans;   }      ll gcd(ll a,ll b){    if(a==0) return b;    return gcd(b % a , a);   }      bool comp(const pair<int,int> &a,const pair<int,int> &b){       return a.second>b.second;   }      ll n,m;   set<ll> has;   vector<ll> input;      void solve(ll l,ll r){    ll sum=0;    for(ll i=l;i<r+1;i++){     sum+=input[i];    }    has.insert(sum);    ll mid=(input[l]+input[r])/2;    ll pos=-1;    for(ll i=l;i<r+1;i++){     if(input[i]<=mid){      pos=i;     }     else{      break;     }    }    if(pos==-1 || pos==r) return;    solve(l,pos);    solve(pos+1,r);   }   void randomevent(){    ll right=n;    while(right>=0 && input[right-1]==right){     right--;    }    double f=(right>0) ? 1:0;    for(ll i=0;i<m;i++){     ll r;cin>>r;     double p;cin>>p;     if(r>=right){      f*=(1-p);     }    }    cout<<fixed<<setprecision(12)<<(1-f)<<endl;   }            int main(){   #ifndef ONLINE_JUDGE       freopen( input.txt , r , stdin);       freopen( output.txt , w , stdout);   #endif           int t;cin>>t;       while(t--){        cin>>n>>m;        for(ll i=0;i<n;i++){         ll p;cin>>p;         input.push_back(p);        }        randomevent();        input.clear();          }   }