#include<stdio.h>
#include<cstring>
#include<iostream>
using namespace std;
#define maxn 55
int n,m,s,sp,t;
double dp[maxn][maxn][maxn*maxn];
int main()
{
scanf("%d",&t);
while(t--)
{
double ans=0;
scanf("%d%d",&n,&m);
memset(dp,0,sizeof(dp));
dp[1][1][1]=1;
s=n*m;
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
{
sp=i*j;
for(int k=max(i,j); k<=sp; k++)
{
dp[i][j][k+1]+=dp[i][j][k]*(sp-k)/(s-k);
dp[i+1][j][k+1]+=dp[i][j][k]*(n-i)*j/(s-k);
dp[i][j+1][k+1]+=dp[i][j][k]*(m-j)*i/(s-k);
dp[i+1][j+1][k+1]+=dp[i][j][k]*(n-i)*(m-j)/(s-k);
}
}
for(int i=max(n,m); i<=m*n; i++)
ans+=(dp[n][m][i]-dp[n][m][i-1])*i;
printf("%.9lf\n",ans);
}
return 0;
}