#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n, u, v;
  cin >> m >> n;
  for (long long i = 0; i < n; i++) {
    cin >> u >> v;
    if (u % 2 == v % 2) {
      cout << (((u - 1) * (m) + 1) / 2) + v / 2 + v % 2 << endl;
    } else {
      cout << (m * m) / 2 + (m * m) % 2 + ((u - 1) * m) / 2 + v / 2 + v % 2
           << endl;
    }
  }
}
