#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e18;
long long gi() {
  long long x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
void chkmax(T &a, T b) {
  a < b ? a = b : 0;
};
template <typename T>
void chkmin(T &a, T b) {
  a > b ? a = b : 0;
};
long long n, q;
int main() {
  cin >> n >> q;
  long long mid = (n * n + 1) / 2;
  while (q--) {
    long long x = gi(), y = gi();
    if (n & 1) {
      if ((x + y) & 1) {
        if (x & 1)
          printf("%lld\n", mid + (x - 1) / 2 * n + (y + 1) / 2);
        else
          printf("%lld\n", mid + (x - 2) / 2 * n + n / 2 + (y + 1) / 2);
      } else {
        if (x & 1)
          printf("%lld\n", (x - 1) / 2 * n + (y + 1) / 2);
        else
          printf("%lld\n", (x - 2) / 2 * n + n / 2 + 1 + (y + 1) / 2);
      }
    } else {
      if ((x + y) & 1)
        printf("%lld\n", mid + (x - 1) * n / 2 + (y + 1) / 2);
      else
        printf("%lld\n", (x - 1) * n / 2 + (y + 1) / 2);
    }
  }
  return 0;
}
