#include <bits/stdc++.h>
int read() {
  int x = 0;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x;
}
long long f[4][100000 + 5][2];
int n, m;
inline long long& F(int x, int y, int p) {
  if (x == 0) return f[0][y][p];
  if (x == n) return f[1][y][p];
  if (y == 0) return f[2][x][p];
  return f[3][x][p];
}
inline int min(int a, int b) { return a < b ? a : b; }
inline int move(int& x, int& y, int a, int b) {
  int r = min(a > 0 ? n - x : x, b > 0 ? m - y : y);
  x += r * a;
  y += r * b;
  return r;
}
inline void renew(long long& a, long long b) {
  if (a < 1 || b < a) a = b;
}
int main() {
  int k, x = 0, y = 0, xx, yy, p = 1, r;
  long long s = 1, ans;
  n = read();
  m = read();
  k = read();
  F(n, m, 0) = F(0, m, 1) = F(n, 0, 1) = 1;
  for (x = 0, y = 0, p = 1; !F(x, y, p); p = !p) {
    F(x, y, p) = s;
    if (p)
      if (x == 0 || y == 0)
        s += move(x, y, 1, 1);
      else
        s += move(x, y, -1, -1);
    else if (x == 0 || y == m)
      s += move(x, y, 1, -1);
    else
      s += move(x, y, -1, 1);
  }
  while (k--) {
    x = read();
    y = read();
    ans = 0;
    xx = x;
    yy = y;
    r = move(xx, yy, 1, 1);
    if (F(xx, yy, 1)) renew(ans, F(xx, yy, 1) + r);
    xx = x;
    yy = y;
    r = move(xx, yy, -1, -1);
    if (F(xx, yy, 1)) renew(ans, F(xx, yy, 1) + r);
    xx = x;
    yy = y;
    r = move(xx, yy, 1, -1);
    if (F(xx, yy, 0)) renew(ans, F(xx, yy, 0) + r);
    xx = x;
    yy = y;
    r = move(xx, yy, -1, 1);
    if (F(xx, yy, 0)) renew(ans, F(xx, yy, 0) + r);
    printf("%I64d\n", ans - 1);
  }
}
