#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  long long n, q, x, y;
  cin >> n >> q;
  for (long long i = 1; i <= q; i++) {
    cin >> x >> y;
    if ((x + y) % 2 == 0) {
      if (n % 2 == 0) {
        long long linie = n / 2;
        long long first = linie * (x - 1);
        long long kth = (y + 1) / 2;
        cout << first + kth << '\n';
      } else {
        long long linie = n / 2;
        long long lines = linie * (x - 1) + (x - 1) / 2 + (x - 1) % 2;
        long long kth = (y + 1) / 2;
        cout << lines + kth << '\n';
      }
    } else {
      long long depl = (n * n) / 2 + (n * n) % 2;
      if (n % 2 == 0) {
        long long linie = n / 2;
        long long first = linie * (x - 1);
        long long kth = (y + 1) / 2;
        cout << depl + first + kth << '\n';
      } else {
        long long linie = n / 2;
        long long lines = linie * (x - 1) + (x - 1) / 2;
        long long kth = (y + 1) / 2;
        cout << depl + lines + kth << '\n';
      }
    }
  }
  return 0;
}
