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