#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 100010;
const int maxk = 100010;
vector<int> a[(maxn << 1) + 5], b[(maxn << 1) + 5];
long long ans[maxk + 5];
pair<int, int> p[maxk + 5];
const int walk[4][2] = {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}};
int main() {
  int n, m, K;
  scanf("%d%d%d", &n, &m, &K);
  memset(ans, -1, sizeof ans);
  for (int i = (0), i_end_ = (K); i < i_end_; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    p[i] = make_pair(u, v);
    a[u - v + maxn].push_back(i);
    b[u + v].push_back(i);
  }
  int first = 0, second = 0, now = 0;
  long long t = 0;
  while (1) {
    if (now & 1) {
      for (auto uu : b[first + second])
        if (!~ans[uu]) ans[uu] = t + abs(p[uu].first - first);
      b[first + second].clear();
    } else {
      for (auto uu : a[first - second + maxn])
        if (!~ans[uu]) ans[uu] = t + abs(p[uu].first - first);
      a[first - second + maxn].clear();
    }
    int u = walk[now][0], v = walk[now][1];
    int tx = (u > 0 ? n - first : first), ty = (v > 0 ? m - second : second);
    if (tx == ty) break;
    if (tx < ty) {
      if (now & 1)
        (now += 1) &= 3;
      else
        (now += 3) &= 3;
      first += tx * u, second += tx * v;
      t += tx;
    } else {
      if (now & 1)
        (now += 3) &= 3;
      else
        (now += 1) &= 3;
      first += ty * u, second += ty * v;
      t += ty;
    }
  }
  for (int i = (0), i_end_ = (K); i < i_end_; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
