#include <bits/stdc++.h>
using namespace std;
long long n;
int Q;
long long num;
int main() {
  scanf("%lld%d", &n, &Q);
  while (Q--) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    if ((x + y) % 2 == 0) {
      num = max((long long)0, n * ((x - 1) / 2));
      if (y % 2)
        num += (y + 1) / 2;
      else
        num += (n + 1) / 2 + y / 2;
    } else {
      num = (n * n + 1) / 2 + max((long long)0, n * ((x - 1) / 2));
      if (y % 2)
        num += n / 2 + (y + 1) / 2;
      else
        num += y / 2;
    }
    printf("%lld\n", num);
  }
}
