#include <bits/stdc++.h>
using namespace std;
const long long Inf = LONG_LONG_MAX;
void exgcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b, y, x), y = y - a / b * x;
}
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
long long calc(int n, int m, long long x, long long y) {
  int a, b, d = gcd(2 * n, 2 * m);
  long long l = 1ll * 4 * n * m / d;
  exgcd(2 * n, 2 * m, a, b);
  if (a < 0)
    a = -a;
  else
    a = 2 * m / d - a;
  if ((x - y) % d != 0) return Inf;
  x += 1ll * (x - y) / d * a * 2 * n, x -= x / l * l;
  if (x < 0) x += l;
  return x;
}
int main() {
  int n, m, k, x, y, tx, ty;
  long long ans;
  for (cin >> n >> m >> k; k--;)
    cin >> x >> y, tx = 2 * n - x, ty = 2 * m - y,
                   ans = min(min(calc(n, m, x, y), calc(n, m, tx, y)),
                             min(calc(n, m, x, ty), calc(n, m, tx, ty))),
                   cout << (ans == Inf ? -1 : ans) << endl;
}
