#include <bits/stdc++.h>
using namespace std;
int work() {
  long long n, q;
  cin >> n >> q;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    if ((x + y) % 2 == 0) {
      long long w = 0;
      long long a = (x - 1) / 2;
      w += a * n;
      if (x % 2 == 1) {
        w += (y + 1) / 2;
      } else {
        w += (n + 1) / 2;
        w += y / 2;
      }
      cout << w << endl;
    } else {
      long long w = (n * n + 1) / 2;
      long long a = (x - 1) / 2;
      w += a * n;
      if (x % 2 == 1) {
        w += y / 2;
      } else {
        w += n / 2;
        w += (y + 1) / 2;
      }
      cout << w << endl;
    }
  }
  return 0;
}
int main() {
  work();
  return 0;
}
