#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
pair<int, int> p[100005];
int n, m, k;
long long cut;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void exgcd(long long a, long long b, long long& d, long long& x, long long& y) {
  if (!b)
    d = a, x = 1, y = 0;
  else
    exgcd(b, a % b, d, y, x), y -= x * (a / b);
}
long long cal(long long c) {
  long long a, b, d, x, y;
  a = 2LL * n, b = 2LL * m;
  exgcd(a, b, d, x, y);
  if (c % d != 0) return -1;
  x *= c / d, y *= c / d;
  a /= d, b /= d;
  if (x < 0 || y > 0) {
    long long t = max((-x) / b, y / a);
    x += t * b, y -= t * a;
    if (x < 0 || y > 0) x += b, y -= a;
  }
  if (x >= 0 && y <= 0) {
    long long t = min(x / b, (-y) / a);
    x -= t * b, y -= t * a;
  }
  return x;
}
long long solve(int x, int y) {
  long long temp, res = INF, tres;
  temp = cal(1LL * y - x);
  tres = 2LL * n * temp + x;
  if (temp != -1 && tres <= cut) res = min(res, tres);
  temp = cal(2LL * m - x - y);
  tres = 2LL * n * temp + x;
  if (temp != -1 && tres <= cut) res = min(res, tres);
  temp = cal(1LL * x + y - 2 * n);
  tres = 2LL * n * temp + 2 * n - x;
  if (temp != -1 && tres <= cut) res = min(res, tres);
  temp = cal(1LL * x - y + 2 * m - 2 * n);
  tres = 2LL * n * temp + 2 * n - x;
  if (temp != -1 && tres <= cut) res = min(res, tres);
  return res == INF ? -1LL : res;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  cut = 1LL * n * m / gcd(1LL * n, 1LL * m);
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%I64d\n", solve(x, y));
  }
  return 0;
}
