#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
int n,m,j,k;
double s,u,v;
scanf("%d",&n);
while(n--)
{
scanf("%lf%lf",&s,&u);
v = 1.0/(tan(atan(1.0/s)-atan(1.0/u)));
printf("%.lf\n",(v*u-s*(v+u)) ) ;
}
}
atan为arctan