#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
template <typename T>
inline T GCD(T a, T b) {
  long long t;
  while (a) {
    t = a;
    a = b % a;
    b = t;
  }
  return b;
}
template <typename T>
inline T Pow(T base, T exp) {
  long long result = 1;
  while (exp) {
    if (exp & 1) result *= base;
    exp >>= 1;
    base *= base;
  }
  return result;
}
template <typename T>
inline T Mulmod(T a, T b, T c) {
  long long x = 0, y = a % c;
  while (b > 0) {
    if (b & 1) x = (x + y) % c;
    y = (y << 1) % c;
    b >>= 1;
  }
  return x;
}
template <typename T>
inline T Pow(T base, T exp, T mod) {
  long long x = 1, y = base;
  while (exp > 0) {
    if (exp & 1) x = Mulmod(x, y, mod);
    y = Mulmod(y, y, mod);
    exp >>= 1;
  }
  return x;
}
template <typename T>
inline T Cube(T a) {
  return a * a * a;
}
const long long int MOD = (long long int)1e9 + 7;
long long int n, q, m, k;
long long pre(long long int x, long long int y) {
  long long int cnt = (x - 1) * n + y;
  long long int ans = (cnt + 1) / 2;
  if ((x + y) % 2 == 1) {
    ans += (n * n + 1) / 2;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  cin >> q;
  while (q--) {
    long long int x, y;
    cin >> x >> y;
    cout << pre(x, y) << endl;
  }
  return 0;
}
