#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > add[200005], dif[200005];
bool done[100005];
long long ans[100005];
int a = 1, b = 1, c = 0, p;
int n, m, k, i, j;
pair<pair<int, int>, int> pr[100005];
int x = 0, y = 0;
long long tim = 0;
void func() {
  if (c == 0) {
    for (p = 0; p < dif[x - y + 100000].size(); p++) {
      if (!done[dif[x - y + 100000][p].second]) {
        done[dif[x - y + 100000][p].second] = 1;
        ans[dif[x - y + 100000][p].second] =
            tim + abs(dif[x - y + 100000][p].first.second - y);
      }
    }
  } else {
    for (p = 0; p < add[x + y].size(); p++) {
      if (!done[add[x + y][p].second]) {
        done[add[x + y][p].second] = 1;
        ans[add[x + y][p].second] = tim + abs(add[x + y][p].first.second - y);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (i = 0; i < k; i++) {
    cin >> pr[i].first.first >> pr[i].first.second;
    pr[i].second = i;
  }
  sort(pr, pr + k);
  for (i = 0; i < k; i++) {
    add[pr[i].first.first + pr[i].first.second].push_back(make_pair(
        make_pair(pr[i].first.first, pr[i].first.second), pr[i].second));
    dif[pr[i].first.first - pr[i].first.second + 100000].push_back(make_pair(
        make_pair(pr[i].first.first, pr[i].first.second), pr[i].second));
  }
  while (!((x == n && y == m) || (x == 0 && y == m) || (x == n && y == 0))) {
    if (a == 1) {
      if (b == 1) {
        func();
        int q = min(n - x, m - y);
        x += q;
        y += q;
        tim += q;
        if (x == n)
          a = 1 - a;
        else if (y == m)
          b = 1 - b;
      } else {
        func();
        int q = min(n - x, y);
        x += q;
        y -= q;
        tim += q;
        if (x == n)
          a = 1 - a;
        else if (y == 0)
          b = 1 - b;
      }
    } else {
      if (b == 1) {
        func();
        int q = min(x, m - y);
        x -= q;
        y += q;
        tim += q;
        if (x == 0)
          a = 1 - a;
        else if (y == m)
          b = 1 - b;
      } else {
        func();
        int q = min(x, y);
        x -= q;
        y -= q;
        tim += q;
        if (x == 0)
          a = 1 - a;
        else if (y == 0)
          b = 1 - b;
      }
    }
    c = 1 - c;
  }
  for (i = 0; i < k; i++) {
    if (!ans[i]) ans[i] = -1;
  }
  for (i = 0; i < k; i++) cout << ans[i] << "\n";
  return 0;
}
