#include <bits/stdc++.h>
int faster_in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -faster_in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
using namespace std;
const int INF = int(1e9 + 7);
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, q;
  cin >> n >> q;
  while (q--) {
    long long x, y;
    cin >> y >> x;
    if ((x + y) % 2 == 0) {
      long long prev = 0;
      if (n % 2 == 0) {
        prev += (y - 1) * (n / 2);
      } else {
        prev += (y - 1) / 2 * (n / 2);
        prev += (y - 1) / 2 * (n / 2 + 1) + (((y - 1) % 2) * (n / 2 + 1));
      }
      prev += (x + 1) / 2;
      cout << prev << '\n';
    } else {
      long long prev = 0;
      if (n % 2 == 0) {
        prev += (y - 1) * (n / 2);
      } else {
        prev += (y - 1) / 2 * (n / 2 + 1);
        prev += (y - 1) / 2 * (n / 2) + (((y - 1) % 2) * (n / 2));
      }
      prev += (x + 1) / 2;
      long long bef = (n * n) / 2 + (n * n) % 2;
      cout << bef + prev << '\n';
    }
  }
  return 0;
}
