#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
struct Point {
  int x, y;
  long long s;
};
stack<Point> stk;
set<pair<int, int> > S;
struct Seg {
  Point p1, p2;
};
map<pair<int, int>, Seg> M;
int n, m, k;
int finish(Point p) {
  if (p.x == 0 && p.y == 0) return 1;
  if (p.x == 0 && p.y == m) return 1;
  if (p.x == n && p.y == 0) return 1;
  if (p.x == n && p.y == m) return 1;
  return 0;
}
void init() {
  stk.push(Point{0, 0, 0});
  if (n <= m)
    stk.push(Point{n, n, n});
  else
    stk.push(Point{m, m, m});
  S.clear();
  M.clear();
  Point pre = Point{0, 0, 0};
  while (1) {
    Point top = stk.top();
    int k = (top.y - pre.y) / (top.x - pre.x);
    int b = top.y - k * top.x;
    if (S.find(make_pair(k, b)) != S.end()) break;
    S.insert(make_pair(k, b));
    M[make_pair(k, b)] = Seg{pre, top};
    if (finish(top)) break;
    Point nxt;
    long long step;
    if (top.x == 0) {
      if (pre.y < top.y) {
        step = min(m - top.y, n);
        nxt.y = top.y + step;
        nxt.x = step;
      } else {
        step = min(top.y, n);
        nxt.y = top.y - step;
        nxt.x = step;
      }
    } else if (top.x == n) {
      if (pre.y < top.y) {
        step = min(m - top.y, n);
        nxt.y = top.y + step;
        nxt.x = n - step;
      } else {
        step = min(top.y, n);
        nxt.y = top.y - step;
        nxt.x = n - step;
      }
    } else if (top.y == 0) {
      if (pre.x < top.x) {
        step = min(n - top.x, m);
        nxt.y = step;
        nxt.x = top.x + step;
      } else {
        step = min(top.x, m);
        nxt.y = step;
        nxt.x = top.x - step;
      }
    } else if (top.y == m) {
      if (pre.x < top.x) {
        step = min(n - top.x, m);
        nxt.y = m - step;
        nxt.x = top.x + step;
      } else {
        step = min(top.x, m);
        nxt.y = m - step;
        nxt.x = top.x - step;
      }
    }
    nxt.s = top.s + step;
    stk.push(nxt);
    pre = top;
  }
}
long long cal(Point p1, Point p2, Point p) {
  long long step = (((p.x - p1.x) > 0) ? (p.x - p1.x) : -(p.x - p1.x));
  return p1.s + step;
}
int main() {
  cin >> n >> m >> k;
  init();
  for (int i = 1; i <= k; i++) {
    int x, y;
    cin >> x >> y;
    long long ans = 0x3f3f3f3f3f3f3f3fll;
    int k, b;
    k = 1;
    b = y - x;
    if (M.find(make_pair(k, b)) != M.end()) {
      Seg seg = M[make_pair(k, b)];
      ans = min(ans, cal(seg.p1, seg.p2, Point{x, y}));
    }
    k = -1;
    b = x + y;
    if (M.find(make_pair(k, b)) != M.end()) {
      Seg seg = M[make_pair(k, b)];
      ans = min(ans, cal(seg.p1, seg.p2, Point{x, y}));
    }
    if (ans == 0x3f3f3f3f3f3f3f3fll) ans = -1;
    cout << ans << endl;
  }
  return 0;
}
