#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, q, x, y, h, ans = 0;
  cin >> n >> q;
  while (q--) {
    cin >> x >> y;
    h = (n * n - 1) / 2 + 1;
    ans = (n * (x - 1) + y - 1) / 2 + 1;
    if ((x + y) % 2 != 0) ans += h;
    cout << ans << endl;
  }
  return 0;
}
