#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, q;
  cin >> n >> q;
  long long start = (n * n + 1) / 2;
  for (int i = 0; i < q; ++i) {
    long long x, y;
    cin >> x >> y;
    if (n % 2 == 0 && (x + y) % 2 == 0) {
      cout << (n / 2) * (x - 1) + (y + 1) / 2 << '\n';
    } else if (n % 2 == 0 && (x + y) % 2 == 1) {
      cout << start + (n / 2) * (x - 1) + (y + 1) / 2 << '\n';
    } else if (n % 2 == 1 && (x + y) % 2 == 0) {
      --x;
      long long h1 = (x + 1) / 2;
      long long h2 = x - h1;
      cout << h1 * ((n + 1) / 2) + h2 * (n / 2) + (y + 1) / 2 << '\n';
    } else if (n % 2 == 1 && (x + y) % 2 == 1) {
      --x;
      long long h2 = (x + 1) / 2;
      long long h1 = x - h2;
      cout << start + h1 * ((n + 1) / 2) + h2 * (n / 2) + (y + 1) / 2 << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(20);
  cin.tie(0);
  solve();
}
