#include <bits/stdc++.h>
using namespace std;
const long long N = 200100, siz = 20, mod = 1e9 + 7;
long long n, q, x, y, ans;
int main() {
  cin >> n >> q;
  while (q--) {
    cin >> x >> y;
    if (x % 2 == 0 && y % 2 == 0) {
      ans = (x - 1) / 2 * n + (n + 1) / 2 + (y + 1) / 2;
    } else if (x % 2 == 0 && y % 2 == 1) {
      ans = (n * n + 1) / 2 + (x - 1) / 2 * n + n / 2 + (y + 1) / 2;
    } else if (x % 2 == 1 && y % 2 == 0) {
      ans = (n * n + 1) / 2 + (x - 1) / 2 * n + (y + 1) / 2;
    } else {
      ans = (x - 1) / 2 * n + (y + 1) / 2;
    }
    cout << ans << endl;
  }
  return 0;
}
