#include <bits/stdc++.h>
using namespace std;
long long read() {
  char s;
  long long x = 0, f = 1;
  s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x *= 10;
    x += s - '0';
    s = getchar();
  }
  return x * f;
}
long long n, q;
long long x, y;
long long ans;
int main() {
  n = read(), q = read();
  while (q--) {
    x = read(), y = read();
    if (n % 2) {
      if ((x + y) % 2) {
        ans = (x - 1) / 2 * ((n + 1) / 2) + x / 2 * (n / 2) + (y + 1) / 2;
        ans += (n * n + 1) / 2;
      } else {
        ans = (x - 1) / 2 * (n / 2) + x / 2 * ((n + 1) / 2) + (y + 1) / 2;
      }
    } else {
      ans = n / 2 * (x - 1) + (y + 1) / 2;
      if ((x + y) % 2) {
        ans += n * n / 2;
      }
    }
    printf("%lld\n", ans);
  }
}
