#include<cstdio>
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<bitset>
#include<map>
#define test(t) while(t--)
#define cin(n) scanf("%d",&n)
#define cinl(n) scanf("%lld",&n)
#define cout(n) printf("%d\n",n)
#define rep(i,a,n) for(i=a;i<=n;i++)
#define vi vector<int>
#define vii vector< vector<int> >
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define eps 1e-12
#define pb push_back
#define mp make_pair
#define imax (int) 1000000007
#define ill long long
#define gc getchar_unlocked
#include<stack>
using namespace std;
#define mod 1000000007
#define inf 10000000
#include <cstdio>
#include <algorithm>
using namespace std;
ill powe(int aa,int b)
{
ill ans=1;
ill a=aa*1LL;
while(b)
{
if(b&1)
ans=(ans*1LL*a)%mod;
a=(a*1LL*a)%mod;
b=b/2;
}
return ans;
}
ill modinv(int a)
{
return powe(a,mod-2);
}
#define eps 1e-12
#define gc getchar_unlocked
/*
int gcd(int i,int j)
{
if(j==0)
return i;
return gcd(j,i%j);
}
#define MAX 100000001
int a[100000009]={0};
vector<int>v;
int sieve()
{
int i,p,n;
for(i=2;i<=MAX;i+=2)
a[i]=2;
for(i=3;i<=MAX;i+=3)
{
if(a[i]==0)
a[i]=3;
}
for(i=5;i*i<=MAX;)
{
if(a[i]==0)
{
//v.pb(i);
a[i]=i;
}
for(p=i*i;p<=MAX;p+=2*i)
{
if(a[p]==0)
a[p]=i;
}
if(i%6==1)
i+=4;
else
i+=2;
}
for(i=10000;i<=MAX;i++)
{
if(a[i]==0)
{
a[i]=i;
}
}
return 0;
}
*/
double dp[45][45],dp2[45][45];
vector<int>v,s;
int m,n;
ill sum[45];
double sub(int pos,int coun)
{
if(dp2[pos][coun]!=-1)
return dp2[pos][coun];
if(pos==v.size())
{
if(coun>=m)
return dp2[pos][coun]=1;
return dp2[pos][coun]=0;
}
double ret=0;
double val=(powe(2,v[pos])-1)*1.0*sub(pos+1,coun+1);
ret=ret+val;
ret=ret+sub(pos+1,coun);
//cout<<pos<<" "<<coun<<" "<<val<<"\n";
return dp2[pos][coun]=ret;
}
double rec(int pos,int coun)
{
if(dp[pos][coun]!=-1)
return dp[pos][coun];
if(pos==v.size())
return 0;
double ret=0;
ret=ret+rec(pos+1,coun);
double val=(powe(2,v[pos]-1)*1.0*s[pos]);
ret=ret+val*(dp2[pos+1][coun+1])+rec(pos+1,coun+1);
return dp[pos][coun]=ret;
}
int main()
{
int t,i,j,k,l;
cin(t);
while(t--)
{
cin(n);
cin(m);
v.clear();
for(i=0;i<=40;i++)
{
for(j=0;j<=40;j++)
{
dp[i][j]=dp2[i][j]=-1;
}
}
memset(sum,0,sizeof(sum));
s.clear();
for(i=0;i<n;i++)
{
cin(j);
cin(k);
v.pb(j);
sum[j]+=k;
}
vector<int>z;z.clear();
sort(v.begin(),v.end());
int c=1;
for(i=0;i<n;i++)
{
if(!i)
continue;
if(v[i]==v[i-1])
{
c++;
}
else
{
z.pb(c);
s.pb(sum[v[i-1]]);
c=1;
}
}
z.pb(c);
s.pb(sum[v[n-1]]);
v=z;
double den=1;
double sum=0;
sub(0,0);
rec(0,0);
sum=dp[0][0];
den=dp2[0][0];
//cout<<sum<<"\n";
//cout<<den<<"\n";
double ans=(sum*1.0)/(den*1.0);
//cout<<dp2[2][1]<<"\n";
//cout<<v[0]<<" "<<v[1]<<"\n";
if(den==0)
ans=0;
printf("%.7lf\n",ans);
}
return 0;
}
I2luY2x1ZGU8Y3N0ZGlvPgojaW5jbHVkZTxpb3N0cmVhbT4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxjc3RyaW5nPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPHNldD4KI2luY2x1ZGU8cXVldWU+CiNpbmNsdWRlPGNtYXRoPgojaW5jbHVkZTxiaXRzZXQ+CiNpbmNsdWRlPG1hcD4KI2RlZmluZSB0ZXN0KHQpIHdoaWxlKHQtLSkKI2RlZmluZSBjaW4obikgc2NhbmYoIiVkIiwmbikKI2RlZ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p7CiAgICBpZihqPT0wKQogICAgICAgIHJldHVybiBpOwoKICAgIHJldHVybiBnY2QoaixpJWopOwp9CgojZGVmaW5lIE1BWCAxMDAwMDAwMDEKaW50IGFbMTAwMDAwMDA5XT17MH07CnZlY3RvcjxpbnQ+djsKaW50IHNpZXZlKCkKewogICAgaW50IGkscCxuOwoKICAgIGZvcihpPTI7aTw9TUFYO2krPTIpCiAgICAgICAgYVtpXT0yOwogICAgZm9yKGk9MztpPD1NQVg7aSs9MykKICAgIHsKICAgICAgIGlmKGFbaV09PTApCiAgICAgICAgYVtpXT0zOwogICAgICAgfQogICAgZm9yKGk9NTtpKmk8PU1BWDspCiAgICB7CiAgICAgICAgaWYoYVtpXT09MCkKICAgICAgICB7CiAgICAgICAgICAgIC8vdi5wYihpKTsKICAgICAgICAgICAgYVtpXT1pOwogICAgICAgIH0KICAgICAgICBmb3IocD1pKmk7cDw9TUFYO3ArPTIqaSkKICAgICAgICB7CiAgICAgICAgICAgIGlmKGFbcF09PTApCiAgICAgICAgICAgIGFbcF09aTsKICAgICAgICB9CiAgICAgICAgaWYoaSU2PT0xKQogICAgICAgICAgICBpKz00OwogICAgICAgIGVsc2UKICAgICAgICAgICAgaSs9MjsKICAgIH0KCiAgICBmb3IoaT0xMDAwMDtpPD1NQVg7aSsrKQogICAgewogICAgICAgaWYoYVtpXT09MCkKICAgICAgIHsKICAgICAgICAgICBhW2ldPWk7CiAgICAgICB9CiAgICB9CiAgICByZXR1cm4gMDsKfQoqLwpkb3VibGUgZHBbNDVdWzQ1XSxkcDJbNDVdWzQ1XTsKdmVjdG9yPGludD52LHM7CmludCBtLG47CmlsbCBzdW1bNDVdOwpkb3VibGUgc3ViKGludCBwb3MsaW50IGNvdW4pCnsKICAgIGlmKGRwMltwb3NdW2NvdW5dIT0tMSkKICAgICAgICByZXR1cm4gZHAyW3Bvc11bY291bl07CgoKICAgIGlmKHBvcz09di5zaXplKCkpCiAgICB7CiAgICAgICAgaWYoY291bj49bSkKICAgICAgICAgICAgcmV0dXJuIGRwMltwb3NdW2NvdW5dPTE7CiAgICAgICAgcmV0dXJuIGRwMltwb3NdW2NvdW5dPTA7CiAgICB9CgogICAgZG91YmxlIHJldD0wOwoKCiAgICBkb3VibGUgdmFsPShwb3dlKDIsdltwb3NdKS0xKSoxLjAqc3ViKHBvcysxLGNvdW4rMSk7CiAgICByZXQ9cmV0K3ZhbDsKICAgIAogICAgcmV0PXJldCtzdWIocG9zKzEsY291bik7CgogICAgLy9jb3V0PDxwb3M8PCIgIjw8Y291bjw8IiAiPDx2YWw8PCJcbiI7CiAgICByZXR1cm4gZHAyW3Bvc11bY291bl09cmV0Owp9CgogZG91YmxlIHJlYyhpbnQgcG9zLGludCBjb3VuKQp7CiAgICBpZihkcFtwb3NdW2NvdW5dIT0tMSkKICAgICAgICByZXR1cm4gZHBbcG9zXVtjb3VuXTsKCiAgICBpZihwb3M9PXYuc2l6ZSgpKQogICAgICAgIHJldHVybiAwOwoKICAgIGRvdWJsZSByZXQ9MDsKCiAgICByZXQ9cmV0K3JlYyhwb3MrMSxjb3VuKTsKCiAgICBkb3VibGUgdmFsPShwb3dlKDIsdltwb3NdLTEpKjEuMCpzW3Bvc10pOwoKICAgIHJldD1yZXQrdmFsKihkcDJbcG9zKzFdW2NvdW4rMV0pK3JlYyhwb3MrMSxjb3VuKzEpOwoKCiAgICByZXR1cm4gZHBbcG9zXVtjb3VuXT1yZXQ7Cn0KCmludCBtYWluKCkKewogICAgaW50IHQsaSxqLGssbDsKICAgIGNpbih0KTsKCiAgICB3aGlsZSh0LS0pCiAgICB7CiAgICAgICAgY2luKG4pOwogICAgICAgIGNpbihtKTsKICAgICAgICB2LmNsZWFyKCk7CiAgICAgICAgZm9yKGk9MDtpPD00MDtpKyspCiAgICAgICAgewogICAgICAgICAgICBmb3Ioaj0wO2o8PTQwO2orKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZHBbaV1bal09ZHAyW2ldW2pdPS0xOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBtZW1zZXQoc3VtLDAsc2l6ZW9mKHN1bSkpOwogICAgICAgIHMuY2xlYXIoKTsKICAgICAgICBmb3IoaT0wO2k8bjtpKyspCiAgICAgICAgewogICAgICAgICAgICBjaW4oaik7CiAgICAgICAgICAgIGNpbihrKTsKICAgICAgICAgICAgdi5wYihqKTsKICAgICAgICAgICAgc3VtW2pdKz1rOwogICAgICAgIH0KICAgICAgICB2ZWN0b3I8aW50Pno7ei5jbGVhcigpOwogICAgICAgIHNvcnQodi5iZWdpbigpLHYuZW5kKCkpOwoKICAgICAgICBpbnQgYz0xOwogICAgICAgIGZvcihpPTA7aTxuO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKCFpKQogICAgICAgICAgICAgICAgY29udGludWU7CgogICAgICAgICAgICBpZih2W2ldPT12W2ktMV0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGMrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHoucGIoYyk7CiAgICAgICAgICAgICAgICBzLnBiKHN1bVt2W2ktMV1dKTsKICAgICAgICAgICAgICAgIGM9MTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgICAgIHoucGIoYyk7CiAgICAgICAgICAgIHMucGIoc3VtW3Zbbi0xXV0pOwoKCiAgICAgICAgdj16OwogICAgICAgIGRvdWJsZSBkZW49MTsKCiAgICAgICAgZG91YmxlICBzdW09MDsKCiAgICAgICAgc3ViKDAsMCk7CiAgICAgICAgcmVjKDAsMCk7CiAgICAgICAgc3VtPWRwWzBdWzBdOwogICAgICAgIGRlbj1kcDJbMF1bMF07CgogICAgICAgIC8vY291dDw8c3VtPDwiXG4iOwogICAgICAgIC8vY291dDw8ZGVuPDwiXG4iOwogICAgICAgIAogICAgICAgIGRvdWJsZSBhbnM9KHN1bSoxLjApLyhkZW4qMS4wKTsKICAgICAgICAvL2NvdXQ8PGRwMlsyXVsxXTw8IlxuIjsKICAgICAgICAvL2NvdXQ8PHZbMF08PCIgIjw8dlsxXTw8IlxuIjsKICAgICAgICBpZihkZW49PTApCiAgICAgICAgICAgIGFucz0wOwogICAgICAgIHByaW50ZigiJS43bGZcbiIsYW5zKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==