#include<cstdio>
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,y,x,a,b;
int f[15];
long long ans;
int main()
{
freopen("infinit.in","r",stdin);
freopen("infinit.out","w",stdout);
f[1]=1;f[2]=1;f[3]=2;f[4]=3;f[5]=3;f[6]=4;f[7]=4;f[8]=5;f[9]=6;f[10]=6;
f[11]=7;f[12]=8;f[13]=6;
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
scanf("%lld%lld",&a,&b);
k=(b-a)/13;
x=f[a%13]+(a/13)*f[13];
y=f[b%13]+(b/13)*f[13];
ans=y-x;
printf("%lld\n",ans);
}
return 0;
}