#include <bits/stdc++.h>
using namespace std;
long long n, q, a, b, val;
int main() {
  cin >> n >> q;
  while (q--) {
    cin >> a >> b;
    val = 0;
    if ((a + b) % 2 == 0) {
      if (n % 2 == 0) {
        val += (n / 2) * (a - 1);
        val += (b + 1) / 2;
      } else {
        val += n * ((a - 1) / 2);
        if (a % 2)
          val += (b + 1) / 2;
        else
          val += (n + 1) / 2 + b / 2;
      }
    } else {
      if (n % 2 == 0) {
        val += n * n / 2;
        val += (n / 2) * (a - 1);
        val += (b + 1) / 2;
      } else {
        val += n * n / 2 + 1;
        val += n * ((a - 1) / 2);
        if (a % 2)
          val += b / 2;
        else
          val += n / 2 + (b + 1) / 2;
      }
    }
    cout << val << '\n';
  }
}
