#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  while (cin >> n >> q) {
    while (q--) {
      long long x, y;
      cin >> x >> y;
      long long ans = (x - 1) * n + y + 1;
      if ((x + y) % 2) {
        ans += n * n;
      }
      cout << ans / 2 << endl;
    }
  }
  return 0;
}
