#include <bits/stdc++.h>
using namespace std;
long long N, Q;
long long X, Y;
int main() {
  for (cin >> N >> Q; cin >> X >> Y;
       cout << ((X + Y) & 1) * ((N * N + 1) >> 1) + (((X - 1) * N + Y + 1) >> 1)
            << '\n') {
  }
}
