#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
long long n, m, k;
map<long long, vector<pair<long long, long long> > > d1;
map<long long, vector<pair<long long, long long> > > d2;
long long ans[maxn];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    d1[x + y].push_back({i, x});
    d2[x - y].push_back({i, x});
  }
  for (long long i = 0; i < k; i++) {
    ans[i] = -1;
  }
  long long curx = 0, cury = 0;
  long long dx = 1, dy = 1;
  for (long long q = 0;;) {
    if (dx + dy == 0) {
      for (auto i : d1[curx + cury]) {
        if (ans[i.first] == -1) {
          ans[i.first] = q + abs(curx - i.second);
        }
      }
    } else {
      for (auto i : d2[curx - cury]) {
        if (ans[i.first] == -1) {
          ans[i.first] = q + abs(curx - i.second);
        }
      }
    }
    long long t = n + m;
    if (dx > 0)
      t = min(t, n - curx);
    else
      t = min(t, curx);
    if (dy > 0)
      t = min(t, m - cury);
    else
      t = min(t, cury);
    curx += t * dx;
    cury += t * dy;
    if (curx == n || curx == 0) {
      if (cury == m || cury == 0) break;
      dx = -dx;
    }
    if (cury == m || cury == 0) dy = -dy;
    q += t;
  }
  for (long long i = 0; i < k; i++) {
    cout << ans[i] << '\n';
  }
}
