#include <bits/stdc++.h>
using namespace std;
long long lmx[3][100005], lmy[3][100005];
int main() {
  ios_base::sync_with_stdio(0);
  long long int i, j, x, n, cnt = 0, m, y, k, g, flg, cx, cy, dx, dy, ct;
  cin >> n >> m >> k;
  pair<long long, long long> p[k + 1];
  long long an[k + 1];
  for (i = 1; i <= k; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (i = 1; i <= max(n, m); i++) {
    lmx[0][i] = lmx[1][i] = lmy[0][i] = lmy[1][i] = 1e15;
  }
  for (i = 1; i <= k; i++) an[i] = 1e15;
  cx = cy = 0;
  dx = dy = 1;
  ct = 0;
  while (1) {
    if (dx && dy) {
      g = min(n - cx, m - cy);
      cx += g;
      cy += g;
      ct += g;
      if (cx == n) {
        lmx[1][cy] = ct;
        dx = 0;
      }
      if (cy == m) {
        lmy[1][cx] = ct;
        dy = 0;
      }
    } else if (!dx && dy) {
      g = min(cx, m - cy);
      cx -= g;
      cy += g;
      ct += g;
      if (cx == 0) {
        lmx[0][cy] = ct;
        dx = 1;
      }
      if (cy == m) {
        lmy[1][cx] = ct;
        dy = 0;
      }
    } else if (dx && !dy) {
      g = min(n - cx, cy);
      cx += g;
      cy -= g;
      ct += g;
      if (cx == n) {
        lmx[1][cy] = ct;
        dx = 0;
      }
      if (cy == 0) {
        lmy[0][cx] = ct;
        dy = 1;
      }
    } else {
      g = min(cx, cy);
      cx -= g;
      cy -= g;
      ct += g;
      if (cx == 0) {
        lmx[0][cy] = ct;
        dx = 1;
      }
      if (cy == 0) {
        lmy[0][cx] = ct;
        dy = 1;
      }
    }
    if ((cy == 0 || cy == m) && (cx == n || cx == 0)) break;
  }
  long long t1, t2;
  for (i = 1; i <= k; i++) {
    x = p[i].first;
    y = p[i].second;
    g = min(n - x, m - y);
    cx = x + g;
    cy = y + g;
    if (cx == n)
      t1 = lmx[1][cy];
    else
      t1 = lmy[1][cx];
    g = min(x, y);
    cx = x - g;
    cy = y - g;
    if (cx == 0)
      t2 = lmx[0][cy];
    else
      t2 = lmy[0][cx];
    if (t1 != 1e15 && t2 != 1e15) {
      if (t1 > t2) {
        an[i] = min(t2 + g, an[i]);
      } else {
        g = min(n - x, m - y);
        an[i] = min(an[i], t1 + g);
      }
    }
    g = min(x, m - y);
    cx = x - g;
    cy = y + g;
    if (cx == 0)
      t1 = lmx[0][cy];
    else
      t1 = lmy[1][cx];
    g = min(n - x, y);
    cx = x + g;
    cy = y - g;
    if (cx == n)
      t2 = lmx[1][cy];
    else
      t2 = lmy[0][cx];
    if (t1 != 1e15 && t2 != 1e15) {
      if (t1 > t2) {
        an[i] = min(an[i], t2 + g);
      } else {
        g = min(x, m - y);
        an[i] = min(an[i], t1 + g);
      }
    }
    if (an[i] >= 1e14) an[i] = -1;
  }
  for (i = 1; i <= k; i++) {
    cout << an[i] << endl;
  }
}
