#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x % 2 == y % 2) {
      long long s = (((long long)x - 1) / 2) * n + 1;
      s += (y / 2 - (y % 2 == 0));
      if (x % 2 == 0) {
        s += n / 2 + (n % 2 != 0);
      }
      printf("%I64d\n", s);
    } else {
      long long s = ((long long)n * n / 2 + ((long long)n * n % 2 != 0) + 1) +
                    (((long long)x - 1) / 2 * n);
      if (x % 2 == 0) {
        s += n / 2;
      }
      s += (y / 2 - (y % 2 == 0));
      printf("%I64d\n", s);
    }
  }
  return 0;
}
