#include <bits/stdc++.h>
using namespace std;
int n, m;
int vx = 1, vy = 1;
bool inside(int x, int y) { return x >= 0 && x <= n && y >= 0 && y <= m; }
pair<int, int> searchEdge(int x, int y) {
  int low = 1, high = max(n, m), res = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (inside(x + vx * mid, y + vy * mid)) {
      low = mid + 1;
      res = mid;
    } else
      high = mid - 1;
  }
  return {x + vx * res, y + vy * res};
}
int getDis(int x, int y, int xt, int yt) { return (xt - x) / vx; }
int main() {
  cin >> n >> m;
  int k;
  cin >> k;
  vector<int> X(k), Y(k);
  map<pair<int, int>, vector<int> > M;
  for (int i = 0; i < k; i++) {
    cin >> X[i] >> Y[i];
    vx = vy = 1;
    M[searchEdge(X[i], Y[i])].push_back(i);
    vx = -1;
    M[searchEdge(X[i], Y[i])].push_back(i);
    vy = -1;
    M[searchEdge(X[i], Y[i])].push_back(i);
    vx = 1;
    M[searchEdge(X[i], Y[i])].push_back(i);
    vy = 1;
  }
  long long cnt = 0;
  vector<long long> ans(k, -1);
  int x = 0, y = 0;
  bool fine = true;
  vx = vy = 1;
  while (fine || (x != 0 && x != n) || (y != 0 && y != m)) {
    fine = false;
    for (int p : M[{x, y}]) {
      if (ans[p] == -1) ans[p] = cnt + getDis(x, y, X[p], Y[p]);
    }
    pair<int, int> nxt = searchEdge(x, y);
    cnt += getDis(x, y, nxt.first, nxt.second);
    x = nxt.first, y = nxt.second;
    if (x == 0 || x == n)
      vx *= -1;
    else
      vy *= -1;
  }
  for (long long a : ans) cout << a << "\n";
  return 0;
}
