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