#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 10;
const int MIN = 5e3 + 10;
const int MAXI = INT_MAX;
const int MINI = -INT_MAX;
const long long MAXL = (1e17 + 10);
const long long MINL = -(1e17 + 10);
long long n, m, k, x, y, t, tx, ty, px, py, tim;
bool up = true, r = true, l = false, down = false;
map<pair<long long, long long>, vector<pair<long long, long long> > > adj;
map<pair<long long, long long>, long long> ans;
pair<long long, long long> p[MAX];
double dis(int a, int b, int c, int d) {
  return double(double(a - c) / double(b - d));
}
bool ok() {
  if (x == 0 & y == 0) return false;
  if (x == n && y == 0) return false;
  if (x == 0 && y == m) return false;
  if (x == n && y == m) return false;
  return true;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    scanf("%lld%lld", &x, &y);
    p[i].first = x, p[i].second = y;
    t = min(n - x, m - y);
    adj[make_pair(x + t, y + t)].push_back(make_pair(x, y));
    t = min(x, m - y);
    adj[make_pair(x - t, y + t)].push_back(make_pair(x, y));
    t = min(n - x, y);
    adj[make_pair(x + t, y - t)].push_back(make_pair(x, y));
    t = min(x, y);
    adj[make_pair(x - t, y - t)].push_back(make_pair(x, y));
  }
  x = 0, y = 0;
  while (true) {
    if (r && up) {
      t = min(n - x, m - y);
      tx = x + t, ty = y + t;
      for (int i = 0; i < adj[make_pair(tx, ty)].size(); i++) {
        px = adj[make_pair(tx, ty)][i].first,
        py = adj[make_pair(tx, ty)][i].second;
        if (dis(tx, ty, px, py) == dis(px, py, x, y))
          if (!ans[make_pair(px, py)]) ans[make_pair(px, py)] = tim + (px - x);
      }
      tim += t, x = tx, y = ty;
      ans[make_pair(tx, ty)] = tim;
      if (!ok()) break;
      if (x == n) up = true, l = true, r = false, down = false;
      if (y == m) r = true, down = true, up = false, l = false;
    }
    if (r && down) {
      t = min(n - x, y);
      tx = x + t, ty = y - t;
      for (int i = 0; i < adj[make_pair(tx, ty)].size(); i++) {
        px = adj[make_pair(tx, ty)][i].first,
        py = adj[make_pair(tx, ty)][i].second;
        if (dis(tx, ty, px, py) == dis(px, py, x, y))
          if (!ans[make_pair(px, py)]) ans[make_pair(px, py)] = tim + (px - x);
      }
      tim += t, x = tx, y = ty;
      ans[make_pair(tx, ty)] = tim;
      if (!ok()) break;
      if (x == n) l = true, down = true, up = false, r = false;
      if (y == 0) up = true, r = true, down = false, l = false;
    }
    if (l && up) {
      t = min(x, m - y);
      tx = x - t, ty = y + t;
      for (int i = 0; i < adj[make_pair(tx, ty)].size(); i++) {
        px = adj[make_pair(tx, ty)][i].first,
        py = adj[make_pair(tx, ty)][i].second;
        if (dis(tx, ty, px, py) == dis(px, py, x, y))
          if (!ans[make_pair(px, py)]) ans[make_pair(px, py)] = tim + (x - px);
      }
      tim += t, x = tx, y = ty;
      ans[make_pair(tx, ty)] = tim;
      if (!ok()) break;
      if (x == 0) up = true, r = true, l = false, down = false;
      if (y == m) down = true, l = true, up = false, r = false;
    }
    if (l && down) {
      t = min(x, y);
      tx = x - t, ty = y - t;
      for (int i = 0; i < adj[make_pair(tx, ty)].size(); i++) {
        px = adj[make_pair(tx, ty)][i].first,
        py = adj[make_pair(tx, ty)][i].second;
        if (dis(tx, ty, px, py) == dis(px, py, x, y))
          if (!ans[make_pair(px, py)]) ans[make_pair(px, py)] = tim + (x - px);
      }
      tim += t, x = tx, y = ty;
      ans[make_pair(tx, ty)] = tim;
      if (!ok()) break;
      if (x == 0) r = true, down = true, l = false, up = false;
      if (y == 0) l = true, up = true, r = false, down = false;
    }
  }
  for (int i = 0; i < k; i++) {
    px = p[i].first, py = p[i].second;
    if (px == 0 && py == 0)
      cout << 0 << endl;
    else if (!ans[make_pair(px, py)])
      cout << -1 << endl;
    else
      cout << ans[make_pair(px, py)] << endl;
  }
  return 0;
}
