#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(const T& x) {
  return x * x;
}
template <class T>
inline void updMin(T& a, const T& b) {
  if (b < a) a = b;
}
template <class T>
inline void updMax(T& a, const T& b) {
  if (b > a) a = b;
}
const long long maxn = 500000;
long long n, m, k;
long long x[maxn], y[maxn];
set<pair<pair<long long, long long>, pair<long long, long long> > > used;
long long ans[maxn];
vector<pair<long long, long long> > xplusy[maxn];
vector<pair<long long, long long> > xminusy[maxn];
const long long SHIFT = 200000;
bool use(long long x, long long y, long long dx, long long dy) {
  if (used.find(make_pair(make_pair(x, y), make_pair(dx, dy))) == used.end()) {
    used.insert(make_pair(make_pair(x, y), make_pair(dx, dy)));
    return true;
  } else {
    return false;
  }
}
void updans(long long ind, long long newt, long long oldt) {
  assert(newt > oldt);
  if (ans[ind]) {
    return;
  }
  ans[ind] = newt;
}
void updans(long long x, long long y, long long dx, long long t,
            vector<pair<long long, long long> >& a) {
  for (int i = 0; i < a.size(); i++) {
    updans(a[i].second, t + (a[i].first - x) / dx, t);
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d %d", &x[i], &y[i]);
    xplusy[x[i] + y[i]].push_back(make_pair(x[i], i));
    xminusy[x[i] - y[i] + SHIFT].push_back(make_pair(x[i], i));
  }
  long long x = 0, y = 0, dx = 1, dy = 1, t = 0;
  while (1) {
    if (!use(x, y, dx, dy)) {
      break;
    }
    if (dx + dy == 0) {
      updans(x, y, dx, t, xplusy[x + y]);
    } else {
      updans(x, y, dx, t, xminusy[x - y + SHIFT]);
    }
    long long tdx = 0;
    if (dx > 0) {
      tdx = n - x;
    } else {
      tdx = x;
    }
    long long tdy = 0;
    if (dy > 0) {
      tdy = m - y;
    } else {
      tdy = y;
    }
    long long td = min(tdx, tdy);
    x += dx * td;
    y += dy * td;
    t += td;
    if (tdx < tdy) {
      dx = -dx;
    } else {
      dy = -dy;
    }
    if ((x == 0 || x == n) && (y == 0 || y == m)) {
      break;
    }
  }
  for (long long i = 0; i < k; i++) {
    printf("%I64d\n", ans[i] ? ans[i] : -1);
  }
  return 0;
}
