#include <bits/stdc++.h>
using namespace std;
long long N, Q;
long long even_above(long long row) {
  if (N % 2 == 0) {
    return row * N / 2;
  } else {
    long long even_rows = (row + 1) / 2;
    long long odd_rows = row - even_rows;
    return even_rows * ((N + 1) / 2) + odd_rows * (N / 2);
  }
}
long long even_before(long long row, long long col) {
  if (row % 2 == 0) {
    return col / 2;
  } else {
    return (col + 1) / 2;
  }
  return (col + (row & 1)) / 2;
}
long long solve(long long r, long long c) {
  long long v1 = even_above(r - 1);
  long long v2 = even_before(r, c);
  if ((r + c) % 2 == 0) {
    return v1 + v2;
  } else {
    return (r - 1) * N + c - (v1 + v2) + (N * N + 1) / 2;
  }
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> N >> Q;
  while (Q--) {
    long long r, c;
    cin >> r >> c;
    cout << solve(r, c) << "\n";
  }
}
