#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, q;
  cin >> n >> q;
  long long x, y, ans;
  long long add = (n * n) / 2;
  while (q--) {
    cin >> x >> y;
    if ((x + y) % 2 == 0)
      ans = ceil(((long double)n * ((long double)x - 1) + y) / (long double)2);
    else {
      ans = ceil(((long double)n * ((long double)x - 1) + y) / (long double)2) +
            add;
      if ((n % 2) != 0) ans += 1;
    }
    cout << ans << "\n";
  }
  return 0;
}
