#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int x[100010], y[100010], s[100010], d[100010], sx[100010], dx[100010],
    sp[100010 * 2], dp[100010 * 2];
long long ans[100010];
void ssort(int l, int r) {
  int i = l, j = r, mid = s[(l + r) / 2];
  do {
    while (s[i] < mid) i++;
    while (s[j] > mid) j--;
    if (i <= j) {
      int tmp = s[i];
      s[i] = s[j];
      s[j] = tmp;
      tmp = sx[i];
      sx[i] = sx[j];
      sx[j] = tmp;
      i++;
      j--;
    }
  } while (i <= j);
  if (i < r) ssort(i, r);
  if (j > l) ssort(l, j);
}
void dsort(int l, int r) {
  int i = l, j = r, mid = d[(l + r) / 2];
  do {
    while (d[i] < mid) i++;
    while (d[j] > mid) j--;
    if (i <= j) {
      int tmp = d[i];
      d[i] = d[j];
      d[j] = tmp;
      tmp = dx[i];
      dx[i] = dx[j];
      dx[j] = tmp;
      i++;
      j--;
    }
  } while (i <= j);
  if (i < r) dsort(i, r);
  if (j > l) dsort(l, j);
}
void reader() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d", &x[i], &y[i]);
    s[i] = x[i] + y[i];
    sx[i] = i;
    d[i] = x[i] - y[i] + m;
    dx[i] = i;
  }
  ssort(1, k);
  dsort(1, k);
  s[k + 1] = d[k + 1] = 12345678;
  sp[0] = dp[0] = 0;
  int p = 0;
  for (int i = 1; i <= m + n; i++) {
    while (s[p + 1] <= i) p++;
    sp[i] = p;
  }
  p = 0;
  for (int i = 1; i <= m + n; i++) {
    while (d[p + 1] <= i) p++;
    dp[i] = p;
  }
}
void process() {
  for (int i = 1; i <= k; i++) ans[i] = -1;
  int tx = 0, ty = 0, hor = 1, ver = 1, de;
  long long t = 0;
  while (true) {
    if (hor == 1 && ver == 1) {
      de = min(n - tx, m - ty);
      for (int i = dp[tx - ty + m - 1] + 1; i <= dp[tx - ty + m]; i++)
        if (ans[dx[i]] == -1) ans[dx[i]] = t + x[dx[i]] - tx;
    } else if (hor == -1 && ver == 1) {
      de = min(tx, m - ty);
      for (int i = sp[tx + ty - 1] + 1; i <= sp[tx + ty]; i++)
        if (ans[sx[i]] == -1) ans[sx[i]] = t + tx - x[sx[i]];
    } else if (hor == 1 && ver == -1) {
      de = min(n - tx, ty);
      for (int i = sp[tx + ty - 1] + 1; i <= sp[tx + ty]; i++)
        if (ans[sx[i]] == -1) ans[sx[i]] = t - tx + x[sx[i]];
    } else if (hor == -1 && ver == -1) {
      de = min(tx, ty);
      for (int i = dp[tx - ty + m - 1] + 1; i <= dp[tx - ty + m]; i++)
        if (ans[dx[i]] == -1) ans[dx[i]] = t + tx - x[dx[i]];
    }
    t += de;
    tx += hor * de;
    ty += ver * de;
    if ((tx == 0 && ty == 0) || (tx == n && ty == 0) || (tx == 0 && ty == m) ||
        (tx == n && ty == m))
      break;
    if (tx == n) hor = -1;
    if (tx == 0) hor = 1;
    if (ty == m) ver = -1;
    if (ty == 0) ver = 1;
  }
  for (int i = 1; i <= k; i++) {
    printf("%I64d\n", ans[i]);
  }
}
int main() {
  reader();
  process();
  return 0;
}
