#include <bits/stdc++.h>
using namespace std;
long long n, q, x, y;
inline void read(long long &x) {
  x = 0;
  char ch = getchar();
  bool flag = 0;
  while ('0' > ch || ch > '9') {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  if (flag) x = -x;
}
int main() {
  read(n), read(q);
  long long mid = (long long)((long long)n * (long long)n / 2);
  if (n % 2 != 0) {
    mid++;
    while (q--) {
      long long ans = 0;
      read(x), read(y);
      if ((x + y) % 2 == 0) {
        if (x % 2 == 0)
          ans = (n / 2 + 1) * (x / 2) + (n / 2) * (x / 2 - 1);
        else
          ans = (n / 2 + 1) * (x / 2) + (n / 2) * (x / 2);
        if (y % 2 == 0)
          ans += y / 2;
        else
          ans += y / 2 + 1;
      } else {
        if (x % 2 == 0)
          ans = (n / 2 + 1) * (x / 2) + (n / 2) * (x / 2 - 1);
        else
          ans = (n / 2 + 1) * (x / 2) + (n / 2) * (x / 2);
        ans += mid;
        if (y % 2 == 0)
          ans += y / 2;
        else
          ans += y / 2;
      }
      cout << ans << endl;
    }
  } else {
    while (q--) {
      long long ans = 0;
      read(x), read(y);
      if ((x + y) % 2 == 0) {
        ans = (n / 2) * (x - 1);
        if (x % 2 == 0)
          ans += y / 2;
        else
          ans += y / 2 + 1;
      } else {
        ans = mid;
        ans += (n / 2) * (x - 1);
        if (x % 2 == 0)
          ans += y / 2 + 1;
        else
          ans += y / 2;
      }
      cout << ans << endl;
    }
  }
  return 0;
}
