#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  int query;
  cin >> query;
  while (query--) {
    long long left, right;
    cin >> left >> right;
    if (n % 2 == 0) {
      long long alpha = left * n + right - n;
      ;
      if ((left + right) % 2 == 0) {
        if (alpha % 2 == 0) {
          cout << alpha / 2 << "\n";
        } else {
          cout << alpha / 2 + 1 << "\n";
        }
      } else {
        cout << (n * (1LL) * n) / 2 + (alpha / 2 + alpha % 2) << "\n";
      }
    } else {
      long long alpha = left * n + right - n;
      ;
      if ((left + right) % 2 == 0) {
        if (alpha % 2 == 0) {
          cout << alpha / 2 << "\n";
        } else {
          cout << alpha / 2 + 1 << "\n";
        }
      } else {
        cout << (n * (1LL) * n) / 2 + (alpha / 2 + alpha % 2) + 1 << "\n";
      }
    }
  }
}
