#include <bits/stdc++.h>
using namespace std;
static mt19937 __gen(chrono::steady_clock::now().time_since_epoch().count());
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
constexpr int inf = 0x3f3f3f3f;
constexpr ll lnf = 0x3f3f3f3f3f3f3f3f;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  ll n, q;
  cin >> n >> q;
  while (q--) {
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 2 == 0) {
      y = (y + 1) / 2;
      ll bef = x - 1;
      ll ans = bef / 2 * n;
      if (bef & 1) ans += (n + 1) / 2;
      cout << ans + y << endl;
    } else {
      y = (y + 1) / 2;
      ll bef = x - 1;
      ll ans = bef / 2 * n;
      if (bef & 1) ans += n / 2;
      cout << ans + y + (n * n + 1) / 2 << endl;
    }
  }
  return 0;
}
