#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const long long INF = (long long)1e18;
const double eps = 1e-9;
int n, m, k;
map<pair<pair<int, int>, pair<int, int> >, long long> u;
bool angle(int x, int y) {
  if (x == 0 && y == 0) return 1;
  if (x == n && y == 0) return 1;
  if (x == 0 && y == m) return 1;
  if (x == n && y == m) return 1;
  return 0;
}
int calc(int x, int y, int dx, int dy) {
  int second;
  if (dx == 1 && dy == 1) {
    second = min((n - x) / dx, (m - y) / dy);
  } else if (dx == 1 && dy == -1) {
    second = min((n - x) / dx, (0 - y) / dy);
  } else if (dx == -1 && dy == -1) {
    second = min((0 - x) / dx, (0 - y) / dy);
  } else {
    second = min((0 - x) / dx, (m - y) / dy);
  }
  return second;
}
pair<int, int> get(int x, int y, int dx, int dy) {
  int second = calc(x, y, dx, dy);
  return make_pair(x + second * dx, y + second * dy);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int x = 0, y = 0;
  long long tot = 0;
  int dx = 1, dy = 1;
  while (!angle(x, y) || tot == 0) {
    int second = calc(x, y, dx, dy);
    pair<int, int> p1 = make_pair(x, y),
                   p2 = make_pair(x + second * dx, y + second * dy);
    if (!u.count(make_pair(p1, p2))) u[make_pair(p1, p2)] = tot;
    x += second * dx;
    y += second * dy;
    tot += second;
    if (x == 0) {
      dx = 1;
    } else if (x == n) {
      dx = -1;
    } else if (y == 0) {
      dy = 1;
    } else if (y == m) {
      dy = -1;
    }
  }
  for (int i = 0; i < k; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    pair<int, int> p1 = get(a, b, -1, -1);
    int s1 = calc(a, b, -1, -1);
    pair<int, int> p2 = get(a, b, 1, 1);
    int s2 = calc(a, b, 1, 1);
    pair<int, int> p3 = get(a, b, 1, -1);
    int s3 = calc(a, b, 1, -1);
    pair<int, int> p4 = get(a, b, -1, 1);
    int s4 = calc(a, b, -1, 1);
    long long res = INF;
    if (u.count(make_pair(p1, p2))) res = min(res, u[make_pair(p1, p2)] + s1);
    if (u.count(make_pair(p2, p1))) res = min(res, u[make_pair(p2, p1)] + s2);
    if (u.count(make_pair(p3, p4))) res = min(res, u[make_pair(p3, p4)] + s3);
    if (u.count(make_pair(p4, p3))) res = min(res, u[make_pair(p4, p3)] + s4);
    if (res == INF)
      printf("-1\n");
    else
      printf("%lld\n", res);
  }
  return 0;
}
