#include using namespace std; int N,Q; main() { cin>>N>>Q; for(;Q--;) { long S,T; cin>>S>>T; int cnt=0; while(S0&&S+i<=T)S+=i,cnt++; else { cnt+=__builtin_popcountll(T-S); S=T; } } cout<