#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int N, M, K;
int dx[] = {1, 1, -1, -1}, dy[] = {1, -1, -1, 1};
int stop;
long long wei[1111111][5];
int vst[1111111][5];
int f(int u, int v) {
  if (v == 0) return u;
  if (v == M - 1) return N + u;
  if (u == 0) return N * 2 + v;
  return N * 2 + M + v;
}
int calc_dst(int d, int u, int v) {
  if (d == 0)
    u = N - 1 - u, v = M - 1 - v;
  else if (d == 1)
    u = N - 1 - u, v = v;
  else if (d == 2)
    u = u, v = v;
  else if (d == 3)
    u = u, v = M - 1 - v;
  if (u == v)
    stop = 0;
  else if (u < v)
    stop = 1;
  else
    stop = 2;
  return min(u, v);
}
int rev(int d) {
  if (stop == 2) {
    if (d < 2) return 1 - d;
    return 5 - d;
  }
  return 3 - d;
}
void prepare() {
  int i, j, k, ux, uy, vx, vy, d;
  long long len;
  for (ux = uy = d = 0, len = 0LL;;) {
    int id = f(ux, uy);
    if (vst[id][d]) return;
    vst[id][d] = 1;
    wei[id][d] = len;
    int dst = calc_dst(d, ux, uy);
    ux += dx[d] * dst;
    uy += dy[d] * dst;
    len += (long long)dst;
    d = rev(d);
    if (stop == 0) return;
  }
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  N++;
  M++;
  prepare();
  int i, u, v, j, jj, uu, vv;
  for (i = (0); i < (K); i++) {
    scanf("%d%d", &u, &v);
    long long res = -1;
    for (j = (0); j < (4); j++) {
      int dst = calc_dst(j, u, v);
      uu = u + dx[j] * dst;
      vv = v + dy[j] * dst;
      if (j % 2 == 0)
        jj = 2 - j;
      else
        jj = 4 - j;
      int id = f(uu, vv);
      if (vst[id][jj]) {
        long long len = (long long)dst + wei[id][jj];
        if (res == -1 || res > len) res = len;
      }
    }
    cout << res << endl;
  }
  return 0;
}
