#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 200;
const long long int M = 1000000007;
const long long int INF = M * M;
const int SL = 2500;
struct Point {
  int n, x, y;
  Point(int nn, int xx, int yy) : n(nn), x(xx), y(yy) {}
};
map<int, vector<Point> > fp;
map<int, vector<Point> > ip;
map<int, bool> fv;
map<int, bool> iv;
long long int ans[N];
long long int dist(int x, int y) { return max(x - y, y - x); }
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    fp[x - y].push_back(Point(i, x, y));
    ip[x + y].push_back(Point(i, x, y));
  }
  memset(ans, -1, N * sizeof(long long int));
  int x = 0, y = 0;
  int dx = 1, dy = 1;
  long long int time = 0;
  for (;;) {
    if (dx == dy) {
      if (fv[x - y]) break;
      fv[x - y] = 1;
      for (int i = 0; i < fp[x - y].size(); ++i) {
        Point p = fp[x - y][i];
        long long int d = dist(p.x, x);
        if (ans[p.n] == -1) ans[p.n] = time + d;
      }
      long long int delta = min(x, y);
      if (dx > 0) {
        delta = min(n - x, m - y);
      }
      time += delta;
      x += delta * dx;
      y += delta * dy;
      if ((dx < 0 && y == 0) || (dx > 0 && y == m))
        dy = -dy;
      else
        dx = -dx;
    } else {
      if (iv[x + y]) break;
      iv[x + y] = 1;
      for (int i = 0; i < ip[x + y].size(); ++i) {
        Point p = ip[x + y][i];
        long long int d = dist(p.x, x);
        if (ans[p.n] == -1) ans[p.n] = time + d;
      }
      long long int delta = min(n - x, y);
      if (dx < 0) {
        delta = min(x, m - y);
      }
      time += delta;
      x += delta * dx;
      y += delta * dy;
      if ((dx < 0 && y == m) || (dx > 0 && y == 0))
        dy = -dy;
      else
        dx = -dx;
    }
    if (!x && !y) break;
    if (!x && y == m) break;
    if (x == n && !y) break;
    if (x == n && y == m) break;
  }
  for (int i = 0; i < k; ++i) cout << ans[i] << endl;
}
