# include # include # include using namespace std; const int MOD = 1e9 + 7; int n; vector rez; int total; void solve(int x, int y){ total = 0; for (int i=x; i<=y; i++){ /// the size int aux = 1; while (aux <= i) aux *= 2; total += min(aux, y + 1) - i; } } void read(){ scanf("%d", &n); for (int i=1; i<=n; i++){ int x, y; scanf("%d %d", &x, &y); solve(x, y); rez.push_back(total); } } void write(){ for (int i : rez){ printf("%d\n", i); } } int main(){ read(); write(); return 0; }