#include <bits/stdc++.h>
using namespace std;
const long long M = 200200;
long long n, m;
long long A, B;
long long g, len;
long long gcd(long long a, long long b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  long long x1, y1;
  long long g = gcd(b % a, a, x1, y1);
  x = y1 - x1 * (b / a);
  y = x1;
  assert(a * x + b * y == g);
  return g;
}
long long Find(long long x, long long y) {
  if ((x - y) % g != 0) return -1;
  long long d = (x - y) / g;
  long long mm = 2 * m / g;
  long long nn = 2 * n / g;
  long long a = -d * A;
  long long b = d * B;
  assert(x + a * 2 * n == y + b * 2 * m);
  if (x + a * 2 * n < 0) {
    long long cur = x + 2 * a * n;
    long long need = (-cur + mm * 2 * n - 1) / (mm * 2 * n);
    a += need * mm;
    b += need * nn;
  }
  long long cur = x + 2 * a * n;
  long long need = cur / (mm * 2 * n);
  a -= need * mm;
  b -= need * nn;
  assert(x + a * 2 * n == y + b * 2 * m);
  return x + a * 2 * n;
}
long long k;
long long x[M], y[M];
void read() {
  cin >> n >> m >> k;
  for (long long i = 0; i < k; ++i) {
    cin >> x[i] >> y[i];
  }
  g = gcd(2 * n, 2 * m, A, B);
  len = n * m / (g / 2);
}
long long mmin(long long x, long long y) {
  if (y == -1) return x;
  return min(x, y);
}
long long solve(long long x, long long y) {
  long long ans = 1e18;
  ans = mmin(ans, Find(x, y));
  ans = mmin(ans, Find(2 * n - x, y));
  ans = mmin(ans, Find(x, 2 * m - y));
  ans = mmin(ans, Find(2 * n - x, 2 * m - y));
  if (ans >= len) ans = -1;
  return ans;
}
void kill() {
  for (long long i = 0; i < k; ++i) {
    cout << solve(x[i], y[i]) << "\n";
  }
}
signed main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}
