#include <bits/stdc++.h>
using namespace std;
void init() {
  freopen("CF_18.inp", "r", stdin);
  freopen("CF_18.out", "w", stdout);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  int q;
  cin >> n >> q;
  long long mid = (n * n) / 2;
  if (n % 2 == 1) mid++;
  long long l, r;
  long long kc;
  long long dem3 = 0;
  long long dem2 = 0;
  long long kq = 0;
  long long k = n / 2 + 1;
  while (q--) {
    cin >> l >> r;
    if (l % 2 == r % 2) {
      kc = l - 1;
      if (kc % 2 == 1) {
        dem3 = (l + 1) / 2;
        dem2 = dem3 - 1;
      } else {
        dem3 = kc / 2;
        dem2 = kc / 2;
      }
      if (n % 2 == 1)
        kq = dem3 * k + dem2 * (k - 1);
      else
        kq = kc * (k - 1);
      if (l % 2 == 1) {
        kq += (r + 1) / 2;
      } else
        kq += r / 2;
      cout << kq << "\n";
    } else {
      kc = l - 1;
      if (kc % 2 == 1) {
        dem3 = (l + 1) / 2;
        dem2 = dem3 - 1;
      } else {
        dem3 = kc / 2;
        dem2 = kc / 2;
      }
      if (n % 2 == 1)
        kq = dem3 * (k - 1) + dem2 * k;
      else
        kq = kc * (k - 1);
      if (l % 2 == 1) {
        kq += (r) / 2;
      } else
        kq += (r + 1) / 2;
      cout << mid + kq << "\n";
    }
  }
}
