#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  long long g = gcd(n, m);
  long long l = (n / g) * m;
  long long x = 0, y = 0, dx = 1, dy = 1, t = 0;
  map<pair<pair<long long, long long>, pair<long long, long long> >, long long>
      lines;
  while (true) {
    lines[make_pair(make_pair(x, y), make_pair(dx, dy))] = t;
    long long xx = (dx == 1 ? n - x : x);
    long long yy = (dy == 1 ? m - y : y);
    if (xx < yy) {
      x += dx * xx;
      dx *= -1;
      y += dy * xx;
      t += xx;
    } else {
      y += dy * yy;
      dy *= -1;
      x += dx * yy;
      t += yy;
    }
    if (t == l) break;
  }
  while (k--) {
    long long a, b;
    cin >> a >> b;
    long long ans = l;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        long long da = 2 * i - 1, db = 2 * j - 1;
        long long aa = (da == 1 ? a : n - a);
        long long bb = (db == 1 ? b : m - b);
        long long a3 = a, b3 = b;
        if (aa < bb) {
          a3 -= da * aa;
          b3 -= db * aa;
        } else {
          a3 -= da * bb;
          b3 -= db * bb;
        }
        long long cur = l;
        if (lines.count(make_pair(make_pair(a3, b3), make_pair(da, db))))
          cur = lines[make_pair(make_pair(a3, b3), make_pair(da, db))] +
                min(aa, bb);
        ans = min(ans, cur);
      }
    }
    if (ans >= l) ans = -1;
    cout << ans << "\n";
  }
  return 0;
}
