#include <bits/stdc++.h>
using namespace std;
long long t = 1;
long long oddroweven, oddrowodd, evenroweven, evenrowodd;
void calc(long long n) {
  if (n % 2 == 0) {
    long long x = (n / 2);
    oddrowodd = oddroweven = evenrowodd = evenroweven = x;
  } else {
    long long x = (n - 1) / 2;
    oddroweven = evenrowodd = x + 1;
    oddrowodd = evenroweven = x;
  }
}
long long numeven(long long x) { return (x - 1) / 2; }
long long numodd(long long x) { return x / 2; }
void solve() {
  long long n, x, y, q;
  cin >> n >> q;
  calc(n);
  while (q--) {
    cin >> x >> y;
    if ((x + y) % 2 == 0) {
      long long nov = numeven(x) * evenroweven + numodd(x) * oddroweven;
      nov += (y - 1) / 2;
      cout << nov + 1 << "\n";
    } else {
      long long fac = (n * n) / 2 + (n * n) % 2;
      long long noe = numeven(x) * evenrowodd + numodd(x) * oddrowodd;
      noe += (y - 1) / 2;
      cout << noe + 1 + fac << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (t--) solve();
  return 0;
}
