#include <bits/stdc++.h>
using namespace std;
int IN() {
  int x = 0, f = 0, ch;
  for (; (ch = getchar()) < '0' || ch > '9';) f = (ch == '-');
  for (; ch >= '0' && ch <= '9'; (ch = getchar())) x = x * 10 + ch - '0';
  return f ? -x : x;
}
int N, M, K;
long long Ans[1000005];
struct Nod {
  int x, y, ID;
};
vector<Nod> A[1000005], B[1000005];
void Min(long long& a, long long b) { a = min(a, b); }
int main(int argc, char* argv[]) {
  N = IN();
  M = IN();
  K = IN();
  for (int i = 1, lim = K; i <= lim; i++) {
    int x = IN(), y = IN();
    Ans[i] = (1ll << 60);
    A[x + y].push_back((Nod){x, y, i});
    B[x - y + M].push_back((Nod){x, y, i});
  }
  int s = 0, d = 0, x = 0;
  long long now = 0;
  for (int Tim = 1, lim = 1000000; Tim <= lim; Tim++) {
    if (s == 0) {
      if (d == 0) {
        for (int i = 1, lim = B[-x + M].size(); i <= lim; i++)
          Min(Ans[B[-x + M][i - 1].ID], now + B[-x + M][i - 1].x);
        B[-x + M].clear();
        int t = min(M - x, N);
        if (x + t == M && t == N) break;
        now += t;
        if (x + t == M) {
          s = 1, d = 1, x = t;
        } else {
          s = 2, d = 0, x = x + t;
        }
      } else {
        for (int i = 1, lim = A[x].size(); i <= lim; i++)
          Min(Ans[A[x][i - 1].ID], now + A[x][i - 1].x);
        A[x].clear();
        int t = min(x, N);
        if (x - t == 0 && t == N) break;
        now += t;
        if (x - t == 0) {
          s = 3, d = 1, x = t;
        } else {
          s = 2, d = 1, x = x - t;
        }
      }
    } else if (s == 2) {
      if (d == 0) {
        for (int i = 1, lim = A[x + N].size(); i <= lim; i++)
          Min(Ans[A[x + N][i - 1].ID], now + N - A[x + N][i - 1].x);
        A[x + N].clear();
        int t = min(M - x, N);
        if (x + t == M && t == N) break;
        now += t;
        if (x + t == M) {
          s = 1, d = 0, x = N - t;
        } else {
          s = 0, d = 0, x = x + t;
        }
      } else {
        for (int i = 1, lim = B[N - x + M].size(); i <= lim; i++)
          Min(Ans[B[N - x + M][i - 1].ID], now + N - B[N - x + M][i - 1].x);
        B[N - x + M].clear();
        int t = min(x, N);
        if (x - t == 0 && t == N) break;
        now += t;
        if (x - t == 0) {
          s = 3, d = 0, x = N - t;
        } else {
          s = 0, d = 1, x = x - t;
        }
      }
    } else if (s == 3) {
      if (d == 0) {
        for (int i = 1, lim = A[x].size(); i <= lim; i++)
          Min(Ans[A[x][i - 1].ID], now + A[x][i - 1].y);
        A[x].clear();
        int t = min(x, M);
        if (x - t == 0 && t == M) break;
        now += t;
        if (x - t == 0) {
          s = 0, d = 0, x = t;
        } else {
          s = 1, d = 0, x = x - t;
        }
      } else {
        for (int i = 1, lim = B[x + M].size(); i <= lim; i++)
          Min(Ans[B[x + M][i - 1].ID], now + B[x + M][i - 1].y);
        B[x + M].clear();
        int t = min(N - x, M);
        if (x + t == N && t == M) break;
        now += t;
        if (x + t == N) {
          s = 2, d = 0, x = t;
        } else {
          s = 1, d = 1, x = x + t;
        }
      }
    } else {
      if (d == 0) {
        for (int i = 1, lim = B[x].size(); i <= lim; i++)
          Min(Ans[B[x][i - 1].ID], now + M - B[x][i - 1].y);
        B[x].clear();
        int t = min(x, M);
        if (x - t == 0 && t == M) break;
        now += t;
        if (x - t == 0) {
          s = 0, d = 1, x = M - t;
        } else {
          s = 3, d = 0, x = x - t;
        }
      } else {
        for (int i = 1, lim = A[x + M].size(); i <= lim; i++)
          Min(Ans[A[x + M][i - 1].ID], now + M - A[x + M][i - 1].y);
        A[x + M].clear();
        int t = min(N - x, M);
        if (x + t == N && t == M) break;
        now += t;
        if (x + t == N) {
          s = 2, d = 1, x = M - t;
        } else {
          s = 3, d = 1, x = x + t;
        }
      }
    }
  }
  for (int i = 1, lim = K; i <= lim; i++)
    printf("%I64d\n", Ans[i] == (1ll << 60) ? -1 : Ans[i]);
  return 0;
}
