#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct Pos {
  int x, y;
  Pos() {}
  Pos(int x, int y) : x(x), y(y) {}
};
bool operator<(const Pos &r, const Pos &s) {
  return r.x < s.x || (r.x == s.x && r.y < s.y);
}
Pos operator*(const Pos &r, int s) { return Pos(r.x * s, r.y * s); }
Pos operator+(const Pos &r, const Pos &s) { return Pos(r.x + s.x, r.y + s.y); }
int n, m, k;
map<Pos, long long> dp;
int ddx[] = {-1, -1, 1, 1};
int ddy[] = {-1, 1, -1, 1};
Pos go(Pos cur, int dx, int dy) {
  int xstep, ystep;
  if (dx == 1 && dy == 1) {
    xstep = n - cur.x;
    ystep = m - cur.y;
  } else if (dx == 1 && dy == -1) {
    xstep = n - cur.x;
    ystep = cur.y;
  } else if (dx == -1 && dy == 1) {
    xstep = cur.x;
    ystep = m - cur.y;
  } else if (dx == -1 && dy == -1) {
    xstep = cur.x;
    ystep = cur.y;
  }
  int step = min(xstep, ystep);
  return cur + Pos(dx, dy) * step;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  Pos cur(0, 0);
  dp[cur] = 0;
  int dx = 1;
  int dy = 1;
  long long curt = 0;
  while (1) {
    int xstep, ystep;
    if (dx == 1 && dy == 1) {
      xstep = n - cur.x;
      ystep = m - cur.y;
    } else if (dx == 1 && dy == -1) {
      xstep = n - cur.x;
      ystep = cur.y;
    } else if (dx == -1 && dy == 1) {
      xstep = cur.x;
      ystep = m - cur.y;
    } else if (dx == -1 && dy == -1) {
      xstep = cur.x;
      ystep = cur.y;
    }
    int step = min(xstep, ystep);
    cur = cur + Pos(dx, dy) * step;
    curt += step;
    if (dp.count(cur))
      break;
    else
      dp[cur] = curt;
    if (xstep == ystep) {
      break;
    } else if (xstep < ystep) {
      dx = -dx;
    } else {
      dy = -dy;
    }
  }
  while (k--) {
    int x, y;
    scanf("%d%d", &x, &y);
    long long ans = (1ULL << 63) - 1;
    Pos cur = Pos(x, y);
    for (int d = 0; d < 4; d++) {
      Pos nxt = go(cur, ddx[d], ddy[d]);
      if (!dp.count(nxt)) continue;
      long long val = dp[nxt] + abs(cur.x - nxt.x);
      if (val < ans) ans = val;
    }
    if (ans == (1ULL << 63) - 1)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
}
