#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, q;
  cin >> n >> q;
  long long c;
  if (n % 2)
    c = n * n / 2 + 1;
  else
    c = n * n / 2;
  while (q) {
    long long a, b;
    cin >> a >> b;
    if (!((a + b) % 2)) {
      cout << ((n * (a - 1) + b + 1) / 2) << "\n";
    } else {
      cout << (n * (a - 1) + b + 1) / 2 + c << "\n";
    }
    q--;
  }
}
