#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, q;
  while (cin >> n >> q) {
    for (int i = 0; i < q; i++) {
      long long x, y, res = 0;
      cin >> x >> y;
      long long longRow = (n + 1) / 2;
      long long shortRow = n / 2;
      if ((x + y) % 2 == 0) {
        res += (x - 1) / 2 * n + ((x - 1) % 2) * longRow;
        res += (y + x % 2) / 2;
      } else {
        res += (n * n + 1) / 2;
        res += (x - 1) / 2 * n + ((x - 1) % 2) * shortRow;
        res += (y + ((x + 1) % 2)) / 2;
      }
      cout << res << '\n';
    }
  }
  return 0;
}
