#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, n, q, x, y, numi, sum, ans;
  cin >> n >> q;
  numi = (n + 1) / 2;
  for (i = 0; i < q; i++) {
    cin >> y >> x;
    sum = x + y;
    ans = 0;
    if (y > 1) {
      if (n % 2 != 0) {
        ans +=
            (numi * ((y - 1) - (((y - 1) / 2))) + (((y - 1) / 2) * (numi - 1)));
      } else {
        ans += (numi * (y - 1));
      }
    }
    long long c1, c0, c2;
    c0 = sum / 2;
    c2 = y / 2;
    c1 = c0 - c2;
    if (sum % 2 != 0) {
      ans = ((n * n) / 2) + ((n * (y - 1)) + x) - ans - c1;
      if (n % 2 != 0) ans++;
    } else {
      ans += c1;
    }
    cout << ans << endl;
  }
}
