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