#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:2000000 )   #pragma comment(linker,  /HEAP:2000000 )   using namespace std;   void print_width(long long x) {     std::cout << std::fixed;     std::cout << std::setprecision(x);   }   long long power(long long x, long long y, long long p = 1000000007) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   void printArr(long long a[], long long n) {     for (long long i = 0; i < n; i++) cout << a[i] <<    ;     cout <<   n ;   }   void printVector(std::vector<long long> v) {     for (long long i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout <<   n ;   }   void printVectorPair(std::vector<pair<long long, long long>> v) {     for (long long i = 0; i < v.size(); i++)       cout << v[i].first <<     << v[i].second <<   n ;     ;     cout <<   n ;   }   void initialize(long long arr[], long long n) {     for (long long i = 0; i <= n; i++) arr[i] = i;   }   long long root(long long arr[], long long i) {     while (arr[i] != i) {       arr[i] = arr[arr[i]];       i = arr[i];     }     return i;   }   void Union(long long arr[], long long a, long long b) {     long long root_a = root(arr, a);     long long root_b = root(arr, b);     arr[root_a] = root_b;   }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long power_wm(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   std::vector<long long> vsum(std::vector<long long> a) {     std::vector<long long> s(a.size());     s[0] = a[0];     for (long long i = 1; i <= a.size() - 1; i++) {       s[i] = s[i - 1] + a[i];     }     return s;   }   void time() {}   long long sti(string s) {     long long ans = 0;     long long p = 1;     for (long long i = s.size() - 1; i >= 0; i--) {       ans = (ans + ((long long)(s[i] -  0 ) * p) % 1000000007) % 1000000007;       p = (p * 10) % 1000000007;     }     return ans;   }   long long bfs(long long x, long long y, vector<vector<long long>> &g) {     std::vector<long long> vis(100001, 0);     vis[x] = 1;     queue<long long> q;     q.push(x);     std::vector<long long> level(100001, (long long)1e18);     level[x] = 0;     while (!q.empty()) {       long long p = q.front();       q.pop();       for (long long i = 0; i < g[p].size(); i++) {         long long p2 = g[p][i];         if (vis[p2] == 0) {           if (x == p and y == p2) {             continue;           } else {             q.push(p2);             vis[p2] = 1;             level[p2] = level[p] + 1;           }         }       }     }     return level[y];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long N = 5000001;     std::vector<long long> lp(N, 0);     std::vector<long long> pr;     for (long long i = 2; i <= N - 1; i++) {       if (lp[i] == 0) {         lp[i] = i;         pr.push_back(i);       }       for (long long j = 0;            j < (long long)pr.size() and pr[j] <= lp[i] and i * pr[j] <= N; j++)         lp[i * pr[j]] = pr[j];     }     lp[1] = 1;     std::vector<long long> count(N, 0);     for (long long i = 2; i <= N - 1; i++) {       long long prm = i;       count[i]++;       while (lp[prm] != prm) {         count[i]++;         prm = prm / lp[prm];       }     }     count = vsum(count);     long long t;     cin >> t;     while (t--) {       long long a, b;       cin >> a >> b;       cout << count[a] - count[b] <<   n ;     }     return 0;   }