#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, q;
  cin >> n >> q;
  int l1 = (n + 1) / 2, l2 = (n) / 2;
  while (q--) {
    long long int x, y;
    cin >> x >> y;
    long long int ans = 0;
    if ((x & 1) != (y & 1)) ans = n * n / 2 + (n & 1);
    ans += (x - 1) / 2 * n;
    x -= (x - 1) / 2 * 2;
    if (x == 2) {
      ans += n / 2;
      if ((x & 1) == (y & 1) && (n & 1)) ans++;
    }
    ans += (y + 1) / 2;
    cout << ans << endl;
  }
  return 0;
}
