#include <bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 5e5 + 7;
const int maxm = 5e4 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-12;
long long n, q, x, y;
int main(int argc, char const *argv[]) {
  scanf("%lld%lld", &n, &q);
  while (q--) {
    scanf("%lld%lld", &x, &y);
    long long ans = 0;
    if ((x + y) % 2 == 0) {
      if (n % 2 == 1) {
        if ((x - 1) % 2 == 0)
          ans = ((x - 1) / 2) * n;
        else
          ans = ((x - 2) / 2) * n + ((x - 1) % 2 == 1 ? (n + 1) / 2 : n / 2);
        ans += (y + 1) / 2;
      } else {
        ans = (n / 2) * (x - 1);
        ans += (y + 1) / 2;
      }
    } else {
      ans = (n * n + 1) / 2;
      if (n % 2 == 1) {
        if ((x - 1) % 2 == 0)
          ans += ((x - 1) / 2) * n;
        else
          ans += ((x - 2) / 2) * n + ((x - 1) % 2 == 1 ? n / 2 : (n + 1) / 2);
        ans += (y + 1) / 2;
      } else {
        ans += (n / 2) * (x - 1);
        ans += (y + 1) / 2;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
