class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<>i) def get(self,p): assert 0<=p and p>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def max_right(self,l,f): assert 0<=l and l<=self.n assert f(self.e) if l==self.n: return self.n l+=self.size sm=self.e while(1): while(l%2==0): l>>=1 if not(f(self.op(sm,self.d[l]))): while(l1 and (r%2)): r>>=1 if not(f(self.op(self.d[r],sm))): while(r M: break for k in P[i*j]: R[i].append(k) query = [[] for i in range(M+1)] ans = [0 for i in range(Q)] for i in range(Q): l,r,k = map(int,input().split()) query[k].append((i,l - 1,r - 1)) seg = segtree([0] * N,add,0) for k in range(1,M+1): for r in R[k]: seg.set(r,1) for i,l,r in query[k]: ans[i] = seg.prod(l,r+1) for r in R[k]: seg.set(r,0) for c in ans: print(c)