#include <bits/stdc++.h>
using namespace std;
void euclid(long long a, long long b, long long& x, long long& y,
            long long& d) {
  if (b == 0) {
    d = a;
    x = 1;
    y = 0;
    return;
  }
  long long x0, y0;
  euclid(b, a % b, x0, y0, d);
  x = y0;
  y = x0 - a / b * y0;
}
long long solve(long long x, long long y, long long n, long long m) {
  long long k1, k2, d;
  euclid(2 * m, 2 * n, k2, k1, d);
  if ((x - y) % d == 0) {
    k2 *= (x - y) / d;
    long long cmmmc = 4 * n * m / d;
    y += 2 * m * k2;
    y %= cmmmc;
    if (y < 0) y += cmmmc;
    return y;
  } else {
    return 1000000000000000000LL;
  }
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; ++i) {
    long long x, y;
    cin >> x >> y;
    long long ans =
        min(min(solve(x, y, n, m), solve(2 * n - x, y, n, m)),
            min(solve(x, 2 * m - y, n, m), solve(2 * n - x, 2 * m - y, n, m)));
    if (ans == 1000000000000000000LL)
      cout << -1;
    else
      cout << ans;
    cout << "\n";
  }
}
