#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
long long r1[maxn * 2], r2[maxn * 2];
long long c1[maxn * 2], c2[maxn * 2];
struct Node {
  int r, c;
} res[maxn];
int main(void) {
  int n, m, k;
  while (~scanf("%d %d %d", &n, &m, &k)) {
    memset(r1, -1, sizeof r2);
    memset(r2, -1, sizeof r2);
    memset(c1, -1, sizeof c2);
    memset(c2, -1, sizeof c2);
    for (int i = 0; i < k; ++i) scanf("%d %d", &res[i].r, &res[i].c);
    int dx = 1, dy = 1;
    int xx = 0, yy = 0;
    long long t = 0;
    int ff = 0;
    while (1) {
      ++ff;
      if (ff > 10 * (n + m)) break;
      if (dx == 1 && dy == 1) {
        if (r1[yy - xx + maxn] == -1) r1[yy - xx + maxn] = t;
        if (n - xx < m - yy)
          dx = -1;
        else if (n - xx > m - yy)
          dy = -1;
        else if (n - xx == m - yy) {
          break;
        }
        int tmp = min(n - xx, m - yy);
        t += (long long)tmp;
        xx += tmp;
        yy += tmp;
      } else if (dx == -1 && dy == -1) {
        if (r2[yy - xx + maxn] == -1) r2[yy - xx + maxn] = t;
        if (xx < yy)
          dx = 1;
        else if (xx > yy)
          dy = 1;
        else if (xx == yy) {
          break;
        }
        int tmp = min(xx, yy);
        t += (long long)tmp;
        xx -= tmp;
        yy -= tmp;
      } else if (dx == 1 && dy == -1) {
        if (c1[yy + xx] == -1) c1[yy + xx] = t;
        if (n - xx < yy)
          dx = -1;
        else if (n - xx > yy)
          dy = 1;
        else if (n - xx == yy) {
          break;
        }
        int tmp = min(n - xx, yy);
        t += (long long)tmp;
        xx += tmp;
        yy -= tmp;
      } else if (dx == -1 && dy == 1) {
        if (c2[yy + xx] == -1) c2[yy + xx] = t;
        if (xx < m - yy)
          dx = 1;
        else if (xx > m - yy)
          dy = -1;
        else if (xx == m - yy) {
          break;
        }
        int tmp = min(xx, m - yy);
        t += (long long)tmp;
        xx -= tmp;
        yy += tmp;
      }
    }
    for (int i = 0; i < k; ++i) {
      int xx = res[i].r, yy = res[i].c;
      if (r1[yy - xx + maxn] == -1 && r2[yy - xx + maxn] == -1 &&
          c1[yy + xx] == -1 && c2[yy + xx] == -1) {
        printf("-1\n");
        continue;
      }
      long long t1 = -1, t2 = -1, t3 = -1, t4 = -1;
      if (r1[yy - xx + maxn] != -1)
        t1 = r1[yy - xx + maxn] + (long long)min(xx, yy);
      if (r2[yy - xx + maxn] != -1)
        t2 = r2[yy - xx + maxn] + (long long)min(n - xx, m - yy);
      if (c1[yy + xx] != -1) t3 = c1[yy + xx] + (long long)min(xx, m - yy);
      if (c2[yy + xx] != -1) t4 = c2[yy + xx] + (long long)min(n - xx, yy);
      long long tt = -1;
      if (t1 != -1) {
        if (tt == -1)
          tt = t1;
        else
          tt = min(tt, t1);
      }
      if (t2 != -1) {
        if (tt == -1)
          tt = t2;
        else
          tt = min(tt, t2);
      }
      if (t3 != -1) {
        if (tt == -1)
          tt = t3;
        else
          tt = min(tt, t3);
      }
      if (t4 != -1) {
        if (tt == -1)
          tt = t4;
        else
          tt = min(tt, t4);
      }
      printf("%I64d\n", tt);
    }
  }
  return 0;
}
