#include <iostream>
#include <fstream>

using namespace std;

int main()
{
	ifstream in("FLOAT.IN");
	int t;
	unsigned int p,q;
	in>>t;
	for (int z=0;z<t;z++)
	{
		in>>p>>q;
		int k=0;
		if(q<8388608) k=q-p+1;
		else 
		{
			if(p<8388608)
			{
				k=8388608-p;
				p=8388608;
			}
			for(int i=p;i<=q;i++)
			{
				float t=(float(i));
				//cout<<int(t)<<endl;
				if(i==int(t)) k++;
			}
		}
		
		cout<<k<<endl;
	}
	return 0;
}