#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 1;
using ll = long long;
ll N, M, K;
ll x, y;
ll solution() {
  ll t = (N * N + 1) >> 1;
  ll l = ((x - 1) / 2);
  ll a = l * N + 1, b = t + 1 + l * N;
  x -= l * 2;
  if (N & 1) {
    y = y + x / 2 * N - 1;
    if (y & 1) {
      return b + y / 2;
    } else {
      return a + y / 2;
    }
  } else {
    y -= 1;
    if (x == 1) {
      if (y & 1) {
        return b + y / 2;
      } else {
        return a + y / 2;
      }
    } else {
      b = b + N / 2;
      a = a + N / 2;
      if (y & 1) {
        return a + y / 2;
      } else {
        return b + y / 2;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  while (cin >> N >> K) {
    while (K--) {
      cin >> x >> y;
      cout << solution() << '\n';
    }
  }
  return 0;
}
