#include <bits/stdc++.h>
using namespace std;
int n, m, k, i;
int x[300011], y[300011];
vector<int> pp[300011], mm[300011];
long long ans[300011];
long long abss(long long x) {
  if (x < 0) return -x;
  return x;
}
void solve_pp(int xx, int yy, int dx, int dy, long long now) {
  int id = 100000 + xx - yy;
  for (auto e : pp[id]) ans[e] = min(ans[e], now + abss(xx - x[e]));
  pp[id].clear();
}
void solve_mm(int xx, int yy, int dx, int dy, long long now) {
  int id = xx + yy;
  for (auto e : mm[id]) ans[e] = min(ans[e], now + abss(xx - x[e]));
  mm[id].clear();
}
void solve() {
  int x, y, dx, dy, difx, dify, dif;
  long long now;
  now = 0;
  x = y = 0;
  dx = dy = 1;
  int limit = (n + m) * 10;
  while (limit-- > 0) {
    if (dx * dy == 1)
      solve_pp(x, y, dx, dy, now);
    else
      solve_mm(x, y, dx, dy, now);
    if (dx > 0)
      difx = n - x;
    else
      difx = x;
    if (dy > 0)
      dify = m - y;
    else
      dify = y;
    dif = min(difx, dify);
    x += dx * dif;
    y += dy * dif;
    now += dif;
    if ((x == 0 || x == n) && (y == 0 || y == m)) break;
    if (x == 0 || x == n) dx *= -1;
    if (y == 0 || y == m) dy *= -1;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &x[i], &y[i]);
    pp[100000 + x[i] - y[i]].push_back(i);
    mm[x[i] + y[i]].push_back(i);
    ans[i] = (1LL << 50);
  }
  solve();
  for (i = 1; i <= k; i++) {
    if (ans[i] >= (1LL << 50))
      printf("-1\n");
    else
      printf("%lld\n", ans[i]);
  }
  return 0;
}
