#include using namespace std; int solve(long s, long t, long l, long r){ if (t <= l || r <= s) return 0; else if (s <= l && r <= t) return 1; else{ long long m = (l + r)>>1; int x = solve(s, t, l, m); int y = solve(s, t, m, r); return x + y; } } int main(void){ int n, q; cin >> n >> q; long maxi = pow(2, n); long s, t; for(int i = 0; i < q; i++){ cin >> s >> t; cout << solve(s, t, 0, maxi) << endl; } return 0; }