#include <bits/stdc++.h>
using namespace std;
long long int n, m, t1, t2, tax, acc, acc2;
int main() {
  cin >> n >> m;
  tax = n / 2 + n % 2;
  while (m-- && cin >> t1 >> t2) {
    if (t1 % 2)
      acc = t1 / 2, acc2 = t1 / 2;
    else
      acc = t1 / 2 - 1, acc2 = t1 / 2;
    if ((t1 + t2) % 2) {
      long long int it = (n * n / 2) + (n * n) % 2;
      cout << fixed << setprecision(0)
           << it + acc2 * (n - (n / 2 + n % 2)) + acc * ((n / 2 + n % 2)) +
                  t2 / 2 + t2 % 2
           << "\n";
    } else {
      cout << fixed << setprecision(0)
           << acc2 * (n / 2 + n % 2) + acc * (n - (n / 2 + n % 2)) + t2 / 2 +
                  t2 % 2
           << "\n";
    }
  }
  return 0;
}
