#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, n, i, ans, kk, k, x, y, q;
  cin >> n >> q;
  while (q--) {
    cin >> x >> y;
    k = (n + 1) / 2;
    kk = (n * n + 1) / 2;
    if (n % 2 == 0) {
      ans = (x - 1) * k + (y + 1) / 2;
      if ((x + y) % 2 != 0) {
        ans += kk;
      }
    } else {
      if (x % 2 == 0) {
        ans = (x - 2) * n / 2 + (n + 1) / 2 + (y + 1) / 2;
      } else {
        ans = (x - 1) * n / 2 + (y + 1) / 2;
      }
      if ((x + y) % 2 != 0) {
        ans += kk;
        if (y % 2 != 0) {
          ans--;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
