#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, q;
  scanf("%lld%lld", &n, &q);
  while (q--) {
    long long int x, y;
    scanf("%lld%lld", &x, &y);
    if ((x + y) % 2 == 0) {
      long long int now = (x - 1) * (n / 2);
      if (n % 2) {
        now += (x) / 2;
      }
      now += y / 2;
      if (y % 2 && x % 2) now++;
      printf("%lld\n", now);
    } else {
      long long int now = (x - 1) * (n / 2) + (n * n) / 2;
      if (n % 2) {
        ++now;
        now += (x - 1) / 2;
      }
      now += y / 2;
      if (x % 2 == 0 && y % 2 == 1) now++;
      printf("%lld\n", now);
    }
  }
  return 0;
}
