#include <bits/stdc++.h>
using namespace std;
int N, M, K;
int T;
const int maxn = 111111;
int x[maxn], y[maxn];
int ggg;
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long q = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return q;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long find(int x, int y) {
  if (abs(x - y) % ggg) return 9999999999999LL;
  int t = abs(x - y) / ggg;
  long long a, b;
  exgcd(2 * N, 2 * M, a, b);
  if (x > y) {
    b *= t;
    b %= 2 * N / ggg;
    while (b * 2 * M + y >= 0) b -= 2 * N / ggg;
    b += 2 * N / ggg;
    return b * 2 * M + y;
  } else {
    a *= t;
    a %= 2 * M / ggg;
    while (a * 2 * N + x >= 0) a -= 2 * M / ggg;
    a += 2 * M / ggg;
    return a * 2 * N + x;
  }
}
int main() {
  cin >> N >> M >> K;
  for (int(i) = 0; (i) < (K); (i)++) {
    cin >> x[i] >> y[i];
  }
  ggg = 2 * gcd(N, M);
  for (int(i) = 0; (i) < (K); (i)++) {
    long long minans = 9999999999999LL;
    long long t = find(x[i], y[i]);
    t = min(t, find(2 * N - x[i], y[i]));
    t = min(t, find(2 * N - x[i], 2 * M - y[i]));
    t = min(t, find(x[i], 2 * M - y[i]));
    cout << (t == minans ? -1 : t) << endl;
  }
  return 0;
}
