#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(const T &a) {
  return a * a;
}
const int MAXN = 1e5 + 300;
int n, m, k;
map<int, vector<int> > diff, sum;
int x[MAXN], y[MAXN];
long long ans[MAXN];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < (k); i++) {
    scanf("%d%d", &x[i], &y[i]), ans[i] = 1e18;
    diff[x[i] - y[i]].push_back(i);
    sum[x[i] + y[i]].push_back(i);
  }
  int posX = 1, posY = 1, dirX = 1, dirY = 1;
  long long curTime = 1;
  while (1) {
    if ((posX == 0 && posY == 0) || (posX == n && posY == 0) ||
        (posX == n && posY == m) || (posX == 0 && posY == m))
      break;
    int timeX, timeY;
    if (dirX > 0)
      timeX = n - posX;
    else
      timeX = posX;
    if (dirY > 0)
      timeY = m - posY;
    else
      timeY = posY;
    int t = min(timeX, timeY);
    if (dirX * dirY > 0) {
      for (int i : diff[posX - posY])
        ans[i] = min(ans[i], curTime + abs(x[i] - posX));
      diff[posX - posY].clear();
    } else {
      for (int i : sum[posX + posY])
        ans[i] = min(ans[i], curTime + abs(x[i] - posX));
      sum[posX + posY].clear();
    }
    curTime += t;
    posX += t * dirX;
    posY += t * dirY;
    if (posX == n || posX == 0) dirX = -dirX;
    if (posY == m || posY == 0) dirY = -dirY;
  }
  for (int i = 0; i < (k); i++) {
    printf("%lld\n", ans[i] == 1e18 ? -1 : ans[i]);
  }
}
