#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const int N = 10e5 + 5;
const int OO = 1e9;
const long long MOD = 1000000007;
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    long long res = (long long)ceil(n * 1.0 / 2),
              ans = (long long)(ceil(((long long)n * (long long)n) * 1.0 / 2)),
              ovr, val = 0;
    if (n % 2 == 0) {
      ovr = (long long)((x - 1) * res);
      val = (long long)(ovr + (long long)((y + (y & 1)) / 2));
      if (x % 2 == 0) {
        if (y % 2 == 0) {
          cout << (long long)val;
        } else {
          cout << (long long)(val + ans);
        }
      } else {
        if (y % 2) {
          cout << (long long)val;
        } else {
          cout << (long long)(val + ans);
        }
      }
      cout << '\n';
    } else {
      ovr = (long long)(ceil((x - 1) * 1.0 / 2) * res +
                        ((x - 1) / 2) * (res - 1));
      if (x % 2 == 0) {
        val = (long long)(ovr + ((y) / 2));
        if (y % 2 == 0) {
          cout << (long long)val;
        } else {
          cout << (long long)(val + ans);
        }
      } else {
        val = (long long)(ovr + (long long)((y + (y & 1)) / 2));
        if (y % 2) {
          cout << (long long)val;
        } else {
          cout << (long long)(val + ans);
        }
      }
      cout << '\n';
    }
  }
  return 0;
}
