#include <iostream>
#define MAX 1000000007
using namespace std;

int n,total,i,j,k,st,fn,rez,x[11],y[11];
int main()
{
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>x[i]>>y[i];
    for (i=1; i<=n; i++)
    {
        total=0;
        for (st=x[i]; st<=y[i]; st++)
            for (fn=st; fn<=y[i]; fn++)
            {
                ///intervalul [x,y]
                if (st!=fn)
                    rez=st&(st+1);
                else
                    rez=st&st;
                for (k=st+1; k<=fn; k++)
                    rez=rez&k;
                if (rez>0)
                    total++;
                if (total>=MAX)
                    total-=MAX;
            }
        cout<<total<<"\n";
    }
    return 0;
}