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