//n为询问次数,m为maxx
#include<bits/stdc++.h> using namespace std; int a[1000005]; int cnt[1000005]; void P(int maxx) { for(int i = 2;i <= maxx;i ++) { cnt[i] = cnt[i-1]; if(!a[i]){ for(int k = i;k <= maxx / i;k ++){ a[i * k] = 1; } cnt[i] ++; } } } int main() { int n,m; scanf("%d%d",&n,&m); P(m); for(int i = 1;i <= n;i ++){ int l,r; scanf("%d%d",&l,&r); if(r > m || r < 1 || l < 1 || l > m){ printf("Crossing the line "); } else{ printf("%d ",cnt[r] - cnt[l - 1]); } } }