#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, q;
  cin >> n >> q;
  while (q--) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    ll res = (n * x + y) / 2 + 1;
    if ((x + y) % 2) res += (n * n + 1) / 2;
    cout << res << endl;
  }
}
