#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 5000 + 7;
const long long MOD = 1e9 + 7;
int main() {
  long long n;
  long long T;
  scanf("%lld %lld", &n, &T);
  for (int i = 1; i <= T; i++) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    if (n % 2 == 0) {
      if ((x + y) % 2 == 0) {
        printf("%lld\n", ((x - 1) * n + y + 1) / 2);
      } else {
        printf("%lld\n", ((x - 1) * n + y + 1) / 2 + (n / 2) * (n / 2) +
                             (n / 2) * (n / 2));
      }
    } else {
      if ((x + y) % 2 == 0) {
        printf("%lld\n", ((x - 1) * n + y + 1) / 2);
      } else {
        printf("%lld\n", ((x - 1) * n + y + 1) / 2 +
                             ((n + 1) / 2) * ((n + 1) / 2) + (n / 2) * (n / 2));
      }
    }
  }
}
