#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long x, y;
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 d = exgcd(b, a % b, x, y);
  long long tmp = x;
  x = y;
  y = tmp - a / b * y;
  return d;
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%I64d%I64d%I64d", &n, &m, &k);
  while (k--) {
    scanf("%I64d%I64d", &x, &y);
    long long p, q;
    long long gcd = exgcd(2 * n, -2 * m, p, q);
    bool flag = false;
    long long xx = 1e18;
    if ((x + y - 2 * n) % gcd == 0) {
      flag = true;
      long long qq = (x + y - 2 * n) / gcd * q;
      long long pp = (x + y - 2 * n) / gcd * p;
      long long MOD = abs(2 * m / gcd);
      pp = (pp % MOD + MOD) % MOD;
      qq = (2 * n * pp - (y + x - 2 * n)) / (2 * m);
      xx = min(xx, 2 * qq * m + y);
    }
    if ((2 * m - 2 * n + x - y) % gcd == 0) {
      flag = true;
      long long qq = (2 * m - 2 * n + x - y) / gcd * q;
      long long pp = (2 * m - 2 * n + x - y) / gcd * p;
      long long MOD = abs(2 * m / gcd);
      pp = (pp % MOD + MOD) % MOD;
      qq = (2 * n * pp - (2 * m - 2 * n + x - y)) / (2 * m);
      xx = min(xx, (2 * qq + 1) * m + m - y);
    }
    if ((2 * m - y - x) % gcd == 0) {
      flag = true;
      long long pp = (2 * m - y - x) / gcd * p;
      long long MOD = abs(2 * m / gcd);
      pp = (pp % MOD + MOD) % MOD;
      xx = min(xx, 2 * pp * n + x);
    }
    if ((y - x) % gcd == 0) {
      flag = true;
      long long pp = (y - x) / gcd * p;
      long long MOD = abs(2 * m / gcd);
      pp = (pp % MOD + MOD) % MOD;
      xx = min(xx, 2 * pp * n + x);
    }
    if (flag) {
      printf("%I64d\n", xx);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}
