#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, q;
  cin >> n >> q;
  unsigned long long int midval;
  if (n % 2 == 0) {
    midval = (n * n) / 2;
  } else {
    midval = (n * n) / 2 + 1;
  }
  for (int i = 0; i < q; ++i) {
    unsigned long long int x, y;
    cin >> x >> y;
    unsigned long long int values = ((x - 1) * n + (y - 1)) / 2;
    unsigned long long int answer;
    if ((x + y) % 2 == 0) {
      answer = 1 + values;
    } else {
      answer = midval + 1 + values;
    }
    cout << answer << endl;
  }
}
