#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e15;
int N, M, K;
long long tim;
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long d = gcd(b, a % b, x, y);
  long long tmp = x;
  x = y;
  y = tmp - a / b * y;
  return d;
}
void mininal_x(long long &x, long long &y, long long a, long long b) {
  if (b < 0) b = -b, a = -a;
  long long t = x / b;
  x -= t * b;
  y += t * a;
  while (x < 0) x += b, y -= a;
}
void mininal_y(long long &x, long long &y, long long a, long long b) {
  if (a < 0) a = -a, b = -b;
  long long t = y / a;
  y -= t * a;
  x += t * b;
  while (y < 0) y += a, x -= b;
}
long long calc(int p, int n, int q, int m) {
  static int lastn = 0, lastm = 0;
  static long long xx, yy, dd;
  if (lastn != n || lastm != m) {
    dd = gcd(n, -m, xx, yy);
    lastn = n, lastm = m;
  }
  long long a = n, b = -m, c = q - p;
  long long d = dd, x = xx, y = yy;
  if (c % d != 0) return oo;
  a /= d, b /= d, c /= d;
  x *= c, y *= c;
  mininal_x(x, y, a, b);
  if (y < 0) mininal_y(x, y, a, b);
  if (p + x * n == 0) x += abs(b);
  return p + x * n;
}
long long solve(int x, int y) {
  int nn = N << 1, mm = M << 1;
  long long ret = calc(x, nn, y, mm);
  ret = min(ret, calc(x, nn, mm - y, mm));
  ret = min(ret, calc(nn - x, nn, y, mm));
  ret = min(ret, calc(nn - x, nn, mm - y, mm));
  return ret;
}
int main() {
  for (; scanf("%d%d%d", &N, &M, &K) != EOF;) {
    tim = min(solve(0, 0), solve(N, M));
    tim = min(tim, max(solve(0, M), solve(N, 0)));
    for (int i = (1), _i = (K); i <= _i; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      long long ret = solve(x, y);
      if (ret != oo)
        printf("%I64d\n", ret);
      else
        printf("-1\n");
    }
  }
  return 0;
}
