#include <bits/stdc++.h>
using namespace std;
vector<int> V[2][200005];
int x[100005];
int y[100005];
long long ans[100005];
int main() {
  int n, m, k;
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    for (int i = 1; i <= 200000; i++) {
      for (int j = 0; j < 2; j++) {
        V[j][i].clear();
      }
    }
    for (int i = 1; i <= k; i++) {
      ans[i] = -1;
      scanf("%d%d", &x[i], &y[i]);
      V[0][x[i] + y[i]].push_back(i);
      V[1][x[i] - y[i] + 100000].push_back(i);
    }
    int xx = 0, yy = 0;
    int type = 1;
    long long time = 0;
    while (true) {
      int t;
      if (type) {
        t = xx - yy + 1e5;
      } else {
        t = xx + yy;
      }
      for (int i = 0; i < V[type][t].size(); i++) {
        int tt = V[type][t][i];
        if (ans[tt] == -1) {
          ans[tt] = time + abs(x[tt] - xx);
        }
      }
      int mi;
      if (type) {
        if (yy == 0 || xx == 0) {
          mi = min(n - xx, m - yy);
          xx += mi;
          yy += mi;
        } else {
          mi = min(xx, yy);
          xx -= mi;
          yy -= mi;
        }
      } else {
        if (yy == 0 || xx == n) {
          mi = min(m - yy, xx);
          xx -= mi;
          yy += mi;
        } else {
          mi = min(yy, n - xx);
          xx += mi;
          yy -= mi;
        }
      }
      time += mi;
      type = 1 - type;
      if (xx == 0 && yy == 0) {
        break;
      }
      if (xx == 0 && yy == m) {
        break;
      }
      if (xx == n && yy == 0) {
        break;
      }
      if (xx == n && yy == m) {
        break;
      }
    }
    for (int i = 1; i <= k; i++) {
      printf("%I64d\n", ans[i]);
    }
  }
  return 0;
}
