#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
int a, b, c, d, n, m, k, w, h;
int gcd(int a, int b, long long &first, long long &second) {
  if (a == 0) {
    first = 0;
    second = 1;
    return b;
  }
  long long x1, y1;
  int d = gcd(b % a, a, x1, y1);
  first = y1 - (b / a) * x1;
  second = x1;
  return d;
}
bool findOne(int a, int b, int c, long long &x0, long long &y0, int &g) {
  g = gcd(abs(a), abs(b), x0, y0);
  if (c % g != 0) {
    return 0;
  }
  x0 *= c / g;
  y0 *= c / g;
  if (a < 0) {
    x0 = -x0;
  }
  if (b < 0) {
    y0 = -y0;
  }
  return 1;
}
void shiftSol(long long &first, long long &second, int a, int b,
              long long cnt) {
  first += cnt * b;
  second -= cnt * a;
}
long long findTheOne(int a, int b, int c) {
  if (a < 0) {
    a = -a;
    b = -b;
    c = -c;
  }
  long long first, second;
  int g;
  if (!findOne(a, b, c, first, second, g)) {
    return -1;
  }
  a /= g;
  b /= g;
  int sign_a = a > 0 ? +1 : -1;
  int sign_b = b > 0 ? +1 : -1;
  shiftSol(first, second, a, b, (0 - first) / b);
  if (first < 0) {
    shiftSol(first, second, a, b, sign_b);
  }
  long long lx1 = first;
  shiftSol(first, second, a, b, -(0 - second) / a);
  if (second < 0) {
    shiftSol(first, second, a, b, -sign_a);
  }
  long long lx2 = first;
  long long lx = max(lx1, lx2);
  return lx;
}
long long solve(int a, int p1, int b, int p2) {
  int A = p1;
  int B = -p2;
  int C = b - a;
  long long t = findTheOne(A, B, C);
  if (t == -1) return 8LL * 1000000000 * 1000000000;
  return t * p1 + a;
}
long long solve(int first, int second) {
  long long c1 = solve(first, 2 * w, second, 2 * h);
  long long c2 = solve(w - first + w, 2 * w, second, 2 * h);
  long long c3 = solve(first, 2 * w, h - second + h, 2 * h);
  long long c4 = solve(w - first + w, 2 * w, h - second + h, 2 * h);
  long long r = min(min(c1, c2), min(c3, c4));
  if (r >= 8LL * 1000000000 * 1000000000)
    return -1;
  else
    return r;
}
int main() {
  scanf("%d%d%d", &w, &h, &k);
  for (int _n((k)-1), i(0); i <= _n; i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    long long r = solve(first, second);
    printf("%I64d\n", r);
  }
}
