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