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