#include <bits/stdc++.h>


using namespace std;
ifstream f1("sump.inp");
ofstream f2("sump.out");

int nt[10000],a[10000],b[10000];
int main()
{int n,j,i,tong=0;
f1>>n;
for (i=1;i<=n;i++){f1>>a[i]>>b[i];}
i=1;
while (i<=10000)
{for (j=1;j<=10000/i;j++)
{ nt[i*j]++;

}
i++;}
for (i=1;i<=n;i++)
{ for (j=a[i];j<=b[i];j++)
   {if (nt[j]==2)
    tong=tong+j;}
    f2<<tong<<endl;
    tong=0;
}
    return 0;
}
