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