#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
void debug(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
const int N = 500500;
const int OFFSET = 200200;
long long tmAdd[N];
long long tmSub[N];
pair<int, int> add[N];
pair<int, int> sub[N];
int n, m, k;
void go(int x, int y, bool isAdd, long long tm) {
  if ((x == 0 or x == n) and (y == 0 or y == m) and (x != 0 or y != 0)) {
    return;
  }
  if (isAdd) {
    add[x + y] = make_pair(x, y);
    assert(tmAdd[x + y] == -1);
    tmAdd[x + y] = tm;
    int nx, ny;
    if (x == 0 or y == m) {
      nx = min(n, x + y);
      ny = x + y - nx;
    } else {
      nx = max(0, x + y - m);
      ny = x + y - nx;
    }
    go(nx, ny, false, tm + abs(x - nx));
  } else {
    sub[x - y + OFFSET] = make_pair(x, y);
    assert(tmSub[x - y + OFFSET] == -1);
    tmSub[x - y + OFFSET] = tm;
    int nx, ny;
    if (x == 0 or y == 0) {
      nx = min(n, m + x - y);
      ny = nx - x + y;
    } else {
      nx = max(0, x - y);
      ny = nx - x + y;
    }
    go(nx, ny, true, tm + abs(x - nx));
  }
}
const long long INF = (long long)1e18;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  memset(tmAdd, -1, sizeof(tmAdd));
  memset(tmSub, -1, sizeof(tmSub));
  go(0, 0, false, 0);
  for (int i = 0; i < (k); ++i) {
    int x, y;
    cin >> x >> y;
    long long tm = INF;
    if (tmAdd[x + y] != -1) {
      tm = min(tm, tmAdd[x + y] + abs(add[x + y].first - x));
    }
    if (tmSub[x - y + OFFSET] != -1) {
      tm = min(tm, tmSub[x - y + OFFSET] + abs(sub[x - y + OFFSET].first - x));
    }
    if (tm == INF) {
      tm = -1;
    }
    cout << tm << "\n";
  }
  return 0;
}
