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