#include <bits/stdc++.h>
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  int n, m, k, x = 0, y = 0, dx = 1, dy = 1, xx, yy;
  long long t, tt;
  std::cin >> n >> m >> k;
  std::map<int, std::tuple<int, int, long long>> a, b;
  a[0] = std::make_tuple(x, y, 0);
  for (long long i = 0;;) {
    if ((x == 0 && y == m) || (x == n && (y == 0 || y == m))) break;
    int d = -1;
    if (dx == 1) {
      d = std::min(n - x, dy == 1 ? m - y : y);
    } else {
      d = std::min(x, dy == 1 ? m - y : y);
    }
    x += dx * d;
    y += dy * d;
    if (x == 0 || x == n) dx *= -1;
    if (y == 0 || y == m) dy *= -1;
    if (dx * dy > 0) {
      if (!a.count(y - x)) a[y - x] = std::make_tuple(x, y, i += d);
    } else {
      if (!b.count(y + x)) b[y + x] = std::make_tuple(x, y, i += d);
    }
  }
  std::map<std::pair<int, int>, int> map;
  for (int i = 0; i < k; i++) {
    tt = 1000000002486618624LL;
    std::cin >> xx >> yy;
    if (a.count(yy - xx)) {
      std::tie(x, y, t) = a[yy - xx];
      tt = std::min(t + std::min(std::abs(x - xx), std::abs(y - yy)), tt);
    }
    if (b.count(yy + xx)) {
      std::tie(x, y, t) = b[yy + xx];
      tt = std::min(t + std::min(std::abs(x - xx), std::abs(y - yy)), tt);
    }
    std::cout << (tt < 1000000002486618624LL ? tt : -1) << std::endl;
  }
  return 0;
}
