#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < q; i++) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    long long pos = (a - 1) * n + b;
    long long cont = (pos + 1) / 2;
    if ((a + b) & 1) cont += ((long long)n * n + 1) / 2;
    printf("%lld\n", cont);
  }
  return 0;
}
