#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  return (b < a) ? (a = b, 1) : 0;
}
using ll = long long;
using R = long double;
const R EPS = 1e-9;
inline int sgn(const R &r) { return (r > EPS) - (r < -EPS); }
inline R sq(R x) { return sqrt(max<R>(x, 0.0)); }
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
inline ll extgcd(ll a, ll b, ll &x, ll &y) {
  x = 1, y = 0;
  ll g = a;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= a / b * x;
  return g;
}
int main(void) {
  ll n, m, k;
  scanf("%lld %lld %lld", &n, &m, &k);
  n *= 2, m *= 2;
  ll x, y;
  const ll g = extgcd(n, m, x, y);
  for (int i = int(0); i < int(k); ++i) {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    ll ans = -1;
    for (auto &ai : {a, n - a}) {
      for (auto &bi : {b, m - b}) {
        const ll d = bi - ai;
        if (d % g != 0) continue;
        ll cx = d / g * x, cy = d / g * y;
        if (cx > 0) {
          const ll coef = cx / (m / g);
          cx -= m / g * coef, cy += n / g * coef;
        }
        while (cx > 0) cx -= m / g, cy += n / g;
        if (cy > 0) {
          const ll coef = cy / (n / g);
          cx += m / g * coef, cy -= n / g * coef;
        }
        while (cy > 0) cx += m / g, cy -= n / g;
        if (cx < 0 or cy > 0) continue;
        ll cur = n * cx + ai;
        if (ans == -1 or ans > cur) ans = cur;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
