#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, bool> vis;
map<pair<long long, long long>, long long> tim;
map<pair<long long, long long>, pair<long long, long long> > st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt = 1;
  while (tt--) {
    long long n, m, k;
    cin >> n >> m >> k;
    multiset<pair<long long, long long> > lines;
    long double x = 0, y = 0, mm = 1, c = 0, nx, ny, wall, px = -1, py = -1;
    long long timer = 0;
    while (vis[{x, y}] == 0) {
      vis[{x, y}] = 1;
      tim[{c, mm}] = timer;
      st[{c, mm}] = {x, y};
      pair<long long, long long> pt[4];
      pt[0] = {-c / mm, 0};
      pt[1] = {n, n * mm + c};
      pt[2] = {(m - c) / mm, m};
      pt[3] = {0, c};
      for (int i = 0; i < 4; i++) {
        if ((pt[i].first != px || pt[i].second != py) &&
            (pt[i].first != x || pt[i].second != y) && pt[i].first >= 0 &&
            pt[i].first <= n && pt[i].second >= 0 && pt[i].second <= m) {
          nx = pt[i].first, ny = pt[i].second;
          break;
        }
      }
      timer += abs(y - ny);
      lines.insert({ny - mm * nx, mm});
      mm = -mm;
      c = ny - mm * nx;
      px = x, py = y;
      x = nx, y = ny;
    }
    long long xx, yy, ans;
    long long ix, iy;
    for (int i = 0; i < k; i++) {
      ans = (long long)3000000000000000000;
      cin >> ix >> iy;
      c = iy - ix, m = 1;
      if (tim.count({c, m})) {
        xx = st[{c, m}].first;
        yy = st[{c, m}].second;
        ans = min(ans, tim[{c, m}] + abs(ix - xx));
      }
      c = iy + ix, m = -1;
      if (tim.count({c, m})) {
        xx = st[{c, m}].first;
        yy = st[{c, m}].second;
        ans = min(ans, tim[{c, m}] + abs(iy - yy));
      }
      if (ans == (long long)3000000000000000000) {
        cout << "-1\n";
      } else {
        cout << ans << '\n';
      }
    }
  }
}
