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

long long dp[6005], ndp[6005];

class BeatTheStar {
	public:
	double doesItMatter( int n, int g ) 
	{
		long long sum = n*(n+1)/2;

		for(int j=0;j<6005;j++)
			dp[j] = ndp[j] = 0;

		dp[0] = 1;
		for(int num=1;num<=n;num++)
		{
			// only consider elements other than g
			if( num == g )
				continue;

			// transitions ( knapsack )
			for(int s=0;s+num<=sum;s++)
			{
				// don't take num
				ndp[s] += dp[s];

				// take num
				ndp[num+s] += dp[s];
			}

			// copy new layer to old layer, and reset new layer
			for(int j=0;j<6005;j++)
			{
				dp[j] = ndp[j];
				ndp[j] = 0;
			}
		}

		long double ans = 0;
		for(int s=0;s<=sum;s++)
		{
			// if s is the sum of a good subset
			if( 2*s < sum && 2*(s + g) > sum )
			{
				// count ways of making s, without using g
				ans += dp[s];
			}
		}

		// divide by total outcomes ( number of subsets of 1..n without g )
		ans /= pow(2,n-1);

		return ans;
	}
};

int main()
{
	BeatTheStar b;

	int test;
	cin>>test;
	for(int i=0;i<test;i++)
	{
		int n,g;
		cin>>n>>g;
		cout<<fixed<<setprecision(4)<<b.doesItMatter(n,g)<<"\n";
	}

	return 0;
}