#include <bits/stdc++.h>
using namespace std;
long long n, q;
long long count(long long x) {
  return (n + 1) / 2 * ((x + 1) / 2) + n / 2 * (x / 2);
}
long long odd_count(long long x) {
  return n / 2 * ((x + 1) / 2) + (n + 1) / 2 * (x / 2);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> q;
  long long t = (n * n + 1) / 2;
  for (int i = 1; i <= q; ++i) {
    long long x, y;
    cin >> x >> y;
    if ((x + y) % 2 == 0)
      cout << count(x - 1) + (x % 2 == 1 ? ((y + 1) / 2) : (y / 2)) << endl;
    else {
      cout << odd_count(x - 1) + (x % 2 == 1 ? (y / 2) : ((y + 1) / 2)) + t
           << endl;
    }
  }
  return 0;
}
