class FenwickTree: def __init__(self, size): self.n = size self.tree = [0] * (self.n + 1) def add(self, index, delta): index += 1 while index <= self.n: self.tree[index] += delta index += index & -index def sum(self, index): index += 1 res = 0 while index > 0: res += self.tree[index] index -= index & -index return res L=10**6 f=[[] for i in range(L+1)] for i in range(1,L+1): for j in range(i,L+1,i): f[j]+=[i] f[i]=f[i][-2:] q0=[[] for i in range(L+2)] for i in range(2,L+1): p2,p1=f[i] q0[p2+1]+=[(p1,1)] q0[p1+1]+=[(p1,-1)] q1=[[] for i in range(L+2)] Q=int(input()) ans=[0]*Q for i in range(Q): l,r=map(int,input().split()) if l==1: ans[i]=1 else: q1[l]+=[(r,i)] st=FenwickTree(L+2) for l in range(L+2): for p,v in q0[l]: st.add(p,v) for r,i in q1[l]: ans[i]=st.sum(r) print(*ans,sep="\n")