#include <bits/stdc++.h>
using namespace std;
char s[1000];
long long int dx[] = {-1, 1};
bool valid(char c) { return c >= 'a' && c <= 'z'; }
bool eq(char a, char b) {
  for (long long int i = 0; i < 2; i++) {
    for (long long int j = 0; j < 2; j++) {
      char aa = a + dx[i];
      char bb = b + dx[j];
      if (valid(aa) && valid(bb) && aa == bb) return true;
    }
  }
  return false;
}
int main() {
  long long int n, q;
  scanf(
      "%lld"
      "%lld",
      &n, &q);
  long long int n2 = n / 2;
  long long int n21 = n2 + 1;
  long long int base = (n * n + 1) / 2;
  for (long long int i = 0; i < q; i++) {
    long long int x, y;
    scanf(
        "%lld"
        "%lld",
        &x, &y);
    long long int pre = (x - 1) / 2 * n;
    if (x & 1) {
      if (y & 1) {
      } else {
        pre += base;
      }
      pre += (y + 1) / 2;
    } else {
      if (y & 1) {
        pre += n2;
        pre += base;
      } else {
        if (n & 1)
          pre += n21;
        else
          pre += n2;
      }
      pre += (y + 1) / 2;
    }
    printf(
        "%lld"
        "\n",
        pre);
  }
  return 0;
}
