#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e9;
int n;
int q;
long long find(int x, int y) {
  long long ans = 0;
  if ((x + y) % 2 == 0) {
    long long box = (x - 1) / 2;
    ans += box * n;
    if ((x - 1) % 2 == 1) {
      ans += (n / 2) + (n % 2);
    }
    ans += (y - 1) / 2 + 1;
    return ans;
  } else {
    ans = 1ll * n * n / 2 + (1ll * n * n % 2);
    long long box = (x - 1) / 2;
    ans += box * n;
    if ((x - 1) % 2 == 1) {
      ans += (n / 2);
    }
    ans += (y - 1) / 2 + 1;
    return ans;
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= q; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%I64d\n", find(x, y));
  }
  return 0;
}
