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