#include using namespace std; long solve(long s, long t, long l, long r, int cnt){ if (t <= l || r <= s) return 1; else if (s <= l && r <= t) return 1; else{ long long m = (l + r)>>1; long x = solve(s, t, l, m, 0); long y = solve(s, t, m, r, 0); return x + y + cnt; } } 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, 0) << endl; } return 0; }