#include<bits/stdc++.h>
using namespace std;
long long t,x,s,num[1001];
int main()
{
cin>>t;
for(int i=1; i<=t; i++)
{
cin>>x>>s;
num[i]=2;
if(s>=10000000)
{
num[i]+=1;
if(s>=20000000)
{
num[i]+=1;
if(s>=40000000)
{
num[i]+=1;
if(s>=60000000)
{
num[i]+=1;
}
}
}
}
if(x>=3)
{
num[i]+=1;
if(x>=5)
{
num[i]+=1;
}
}
}
for(int i=1; i<=t; i++)
{
cout<<num[i]<<endl;
}
return 0;
}