#include <fstream>
using namespace std;
int kt(long int a, long int b)
{
	long int tong=0;
	int i,d;
	for (i=a;i<=b;i++)
	{
		for (d=2;d<i;d++)
		if (i%d==0)
		{
			return 0;
		}
		else
		{tong=tong+i;
		return tong;
	}}
}
int main ()
{
	ifstream f("sump.inp");
	ofstream g("sump.out");
	long int n,a[999999],b[999999];
	int i;
	f>>n;
	for (i=1;i<=n;i++)
	{
		f>>a[i]>>b[i];
	}
	for (i=1;i<=n;i++)
	{
		g<<kt(a[i],b[i])<<endl;
	}
	f.close();
	g.close();
}
