#include <bits/stdc++.h>   using namespace std;   long long inf = 1e18;   vector<long long> a;   map<long long, bool> p;   int binp(long long x) {     int l = 0, r = 1e9 + 1;     while (r - l > 1) {       int m = (l + r) / 2;       if (1LL * m * m <= x)         l = m;       else         r = m;     }     return l;   }   int main() {     a.push_back(0);     for (long long i = 2; i <= 1000000; ++i) {       long long cur = i * i * i;       while (inf / i >= cur) {         long long x = binp(cur);         if (!p[cur] && x * x != cur) a.push_back(cur);         p[cur] = 1;         cur *= i;       }       long long x = binp(cur);       if (!p[cur] && x * x != cur) a.push_back(cur);       p[cur] = 1;     }     sort(a.begin(), a.end());     int t;     scanf( %d , &t);     while (t--) {       long long l, r;       scanf( %lld %lld , &l, &r);       long long ans = upper_bound(a.begin(), a.end(), r) -                       upper_bound(a.begin(), a.end(), l - 1);       ans += binp(r) - binp(l - 1);       printf( %lld n , ans);     }     return 0;   }   