#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, res = 0, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - 48, ch = getchar();
  return f * res;
}
int _sta[1 << 8];
inline void write(int val) {
  if (!val) {
    putchar('0');
    return;
  }
  if (val < 0) putchar('-'), val = -val;
  *_sta = 0;
  while (val > 0) _sta[++*_sta] = val % 10, val /= 10;
  for (int i = *_sta, _Lim = 1; i >= _Lim; i--) putchar(_sta[i] + 48);
}
const long long INF = 1e18;
long long Exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  int res = Exgcd(b, a % b, x, y);
  int x_ = x;
  x = y;
  y = x_ - a / b * y;
  return res;
}
int n, m, k;
long long Cal(long long x, long long y) {
  long long a, b;
  long long gcd = Exgcd(2 * n, 2 * m, a, b);
  long long lcm = 1LL * 2 * n * 2 * m / gcd;
  if (a < 0)
    a = -a;
  else
    a = 2 * m / gcd - a;
  if ((x - y) % gcd != 0) return INF;
  x += 1LL * (x - y) / gcd * a * 2 * n;
  x -= x / lcm * lcm;
  if (x < 0) x += lcm;
  return x;
}
int main() {
  n = read();
  m = read();
  k = read();
  while (k--) {
    int x = read(), y = read();
    long long Ans = INF;
    Ans = min(Ans, Cal(x, y));
    Ans = min(Ans, Cal(x, 2 * m - y));
    Ans = min(Ans, Cal(2 * n - x, y));
    Ans = min(Ans, Cal(2 * n - x, 2 * m - y));
    if (Ans < INF)
      printf("%I64d\n", Ans);
    else
      printf("-1\n");
  }
}
