#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
long long n, m, k, nn, mm;
long long g, a, b, c, d;
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0LL) {
    x = 1LL;
    y = 0LL;
    return a;
  } else {
    long long g = gcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long check(long long x, long long y) {
  if ((x - y) % g)
    return INF;
  else {
    long long p = (x - y) / g;
    long long aa = a * p, bb = b * p;
    if (!(bb >= 0LL && aa <= 0LL)) {
      long long k1 = (aa + c - 1LL) / c;
      long long k2 = (-bb + d - 1LL) / d;
      long long kk = max(k1, k2);
      aa -= c * kk;
      bb += d * kk;
    }
    if (bb >= d && aa <= -c) {
      long long k1 = (-aa) / c;
      long long k2 = bb / d;
      long long kk = min(k1, k2);
      aa += c * kk;
      bb -= d * kk;
    }
    return x - aa * nn;
  }
}
int main() {
  cin >> n >> m >> k;
  nn = n << 1;
  mm = m << 1;
  g = gcd(nn, mm, a, b);
  c = mm / g;
  d = nn / g;
  while (k--) {
    long long x, y;
    cin >> x >> y;
    long long ans = min(min(check(x, y), check(x, mm - y)),
                        min(check(nn - x, y), check(nn - x, mm - y)));
    if (ans == INF)
      cout << "-1" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
