#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, nx, ny, dx = 1, dy = 1, mx, my;
int64_t ans[100001], t;
map<int, vector<int>> p, s;
int _x[100001], _y[100001];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < k; ++i) {
    scanf("%d%d", &x, &y);
    p[x + y].emplace_back(i);
    s[x - y].emplace_back(i);
    _x[i] = x;
    _y[i] = y;
  }
  x = y = 0;
  while (1) {
    static int fuck;
    if (++fuck == 1000000) break;
    mx = (dx == 1 ? n - x : x);
    my = (dy == 1 ? m - y : y);
    if (dx == dy) {
      for (auto&& i : s[x - y])
        if (!ans[i]) ans[i] = t + abs(_x[i] - x);
      s[x - y].clear();
    } else {
      for (auto&& i : p[x + y])
        if (!ans[i]) ans[i] = t + abs(_x[i] - x);
      p[x + y].clear();
    }
    dx == 1 ? (x += min(mx, my)) : (x -= min(mx, my));
    dy == 1 ? (y += min(mx, my)) : (y -= min(mx, my));
    t += min(mx, my);
    if ((!x || x == n) && (!y || y == m)) break;
    if (!x || x == n) dx = -dx;
    if (!y || y == m) dy = -dy;
  }
  for (int i = 0; i < k; ++i) printf("%lld\n", ans[i] ? ans[i] : -1);
}
