#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n;
  int a, b, p;
  long long ans, k, sum;
  while (cin >> m >> n) {
    sum = m * m;
    if (m % 2 == 0)
      k = sum / 2;
    else
      k = (sum + 1) / 2;
    while (n--) {
      scanf("%d %d", &a, &b);
      ans = 0;
      p = 0;
      if (a % 2 != b % 2) ans += k, p = 1;
      a--;
      long long s = a / 2;
      ans += s * m;
      s = a - s * 2;
      if (s)
        if (m % 2) {
          if (!p)
            ans += m / 2 + 1;
          else
            ans += m / 2;
        } else
          ans += m / 2;
      if (b % 2) {
        ans += b / 2 + 1;
      } else
        ans += b / 2;
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
