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