#include <bits/stdc++.h>
using namespace std;
void rf() {}
const int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};
const int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};
const int Nx[4] = {0, 0, -1, 1};
const int Ny[4] = {1, -1, 0, 0};
const long long LINF = (long long)5e18;
const int INF = 1e9 + 7;
const int N = 1e5 + 1;
const int MAXN = 1e6 + 50;
const double EPS = 1e-9, PI = 3.14159265359;
inline int get_int() {
  char x = getchar();
  int ret = 0;
  bool neg = 0;
  while (!('0' <= x && x <= '9')) {
    if (x == '-') neg = 1;
    x = getchar();
  }
  while ('0' <= x && x <= '9') {
    ret = ret * 10 + x - '0';
    x = getchar();
  }
  if (neg) ret *= -1;
  return ret;
}
int n, m, k;
int qx[N], qy[N];
vector<int> query[2][N * 3];
long long ans[N];
map<pair<pair<int, int>, pair<int, int> >, bool> was;
int gvelx, gvely;
int velx = 1, vely = 1;
inline bool ok(pair<int, int> cur) {
  gvelx = velx, gvely = vely;
  bool fail = 0;
  if (cur.first >= n) fail = 1, gvelx = -1;
  if (cur.second >= m) fail = 1, gvely = -1;
  if (cur.first <= 0) fail = 1, gvelx = 1;
  if (cur.second <= 0) fail = 1, gvely = 1;
  return !fail;
}
void solve() {
  pair<int, int> cur = make_pair(0, 0);
  long long sum = 0;
  for (long long t = 1;;) {
    if (was.count(make_pair(cur, make_pair(velx, vely)))) break;
    was[make_pair(cur, make_pair(velx, vely))] = 1;
    int l = 1, r = INF;
    int cur_time = -1;
    while (l <= r) {
      int middle = (l + r) / 2;
      if (!ok(make_pair(cur.first + velx * middle,
                        cur.second + vely * middle))) {
        r = middle - 1;
        cur_time = middle;
      } else {
        l = middle + 1;
      }
    }
    pair<int, int> pr = cur;
    cur.first += velx * cur_time;
    cur.second += vely * cur_time;
    if (make_pair(velx, vely) == make_pair(1, 1) ||
        make_pair(velx, vely) == make_pair(-1, -1)) {
      for (auto it : query[1][pr.first - pr.second + N]) {
        if (ans[it] == -1) ans[it] = sum + abs(qx[it] - pr.first);
      }
    } else {
      for (auto it : query[0][pr.first + pr.second]) {
        if (ans[it] == -1) ans[it] = sum + abs(qx[it] - pr.first);
      }
    }
    ok(cur);
    velx = gvelx;
    vely = gvely;
    sum += cur_time;
    t += cur_time + 1;
  }
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0), cin.tie(0);
  rf();
  long double beg = clock();
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> qx[i] >> qy[i];
    query[0][qx[i] + qy[i]].push_back(i);
    query[1][qx[i] - qy[i] + N].push_back(i);
    ans[i] = -1;
  }
  solve();
  for (int i = 0; i < k; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
