#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 1, mod = 1000000007;
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int pro = 1, temp, t, m, n, k, i, j, l, r, mid, x, y, z, rem,
                carry = 0, ind, ans = 0, mx = -LONG_LONG_MAX,
                mn = LONG_LONG_MAX, cnt = 0, curr = 0, prev, sum = 0, flag = 1,
                i1 = -1, i2 = -1;
  cin >> n >> t;
  while (t--) {
    cin >> x >> y;
    if ((x + y) & 1) {
      temp = x / 2;
      curr = temp * (n / 2);
      curr += (x - 1 - temp) * ((n + 1) / 2);
      if (x & 1) {
        curr += y / 2;
      } else {
        curr += (y + 1) / 2;
      }
      curr += (n * n + 1) / 2;
    } else {
      temp = x / 2;
      curr = temp * ((n + 1) / 2);
      curr += (x - 1 - temp) * (n / 2);
      if (y & 1 && x & 1) {
        curr += (y + 1) / 2;
      } else {
        curr += y / 2;
      }
    }
    cout << curr << '\n';
  }
  return 0;
}
