#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  map<long long, vector<pair<long long, long long>>> dp1, dp2;
  map<long long, long long> ans;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    dp1[x + y].push_back({i, x});
    dp2[x - y].push_back({i, x});
    ans[i] = 1e15;
  }
  long long x = 0, y = 0;
  long long d1 = 1, d2 = 1;
  long long d = 0;
  while (true) {
    if (d1 == d2) {
      for (auto p : dp2[x - y]) {
        ans[p.first] = min(ans[p.first], d + abs(p.second - x));
      }
    } else {
      for (auto p : dp1[x + y]) {
        ans[p.first] = min(ans[p.first], d + abs(p.second - x));
      }
    }
    long long cur = n + m;
    if (d1 == -1) {
      cur = min(cur, x);
    } else {
      cur = min(cur, n - x);
    }
    if (d2 == -1) {
      cur = min(cur, y);
    } else {
      cur = min(cur, m - y);
    }
    x += d1 * cur;
    y += d2 * cur;
    d += cur;
    bool xb = ((x == 0) or (x == n));
    bool yb = ((y == 0) or (y == m));
    if (xb and yb) {
      break;
    }
    if (xb) {
      d1 = -d1;
    }
    if (yb) {
      d2 = -d2;
    }
  }
  for (auto i : ans) {
    if (i.second == 1e15) {
      cout << -1 << '\n';
    } else {
      cout << i.second << '\n';
    }
  }
  return 0;
}
