#include <bits/stdc++.h>
using namespace std;
long long n, m, k, ix, iy;
set<pair<long long, long long> > as;
vector<pair<pair<long long, long long>, pair<long long, long long> > > line[2];
void mov0(bool dir, long long &cx, long long &cy, long long &ch) {
  if (cy == 0) {
    ch = min(m - cx, n);
    cx += ch;
    cy += ch;
    return;
  }
  if (cx == 0) {
    ch = min(m, n - cy);
    cx += ch;
    cy += ch;
    return;
  }
  if (cy == n) {
    ch = min(cx, n);
    cx -= ch;
    cy -= ch;
    return;
  }
  if (cx == m) {
    ch = min(m, cy);
    cx -= ch;
    cy -= ch;
    return;
  }
}
void mov1(bool dir, long long &cx, long long &cy, long long &ch) {
  if (cy == 0) {
    ch = min(cx, n);
    cx -= ch;
    cy += ch;
    return;
  }
  if (cx == 0) {
    ch = min(m, cy);
    cx += ch;
    cy -= ch;
    return;
  }
  if (cy == n) {
    ch = min(m - cx, n);
    cx += ch;
    cy -= ch;
    return;
  }
  if (cx == m) {
    ch = min(m, n - cy);
    cx -= ch;
    cy += ch;
    return;
  }
}
void running() {
  long long x = 0, y = 0, cl = 0;
  long long cur = 0;
  bool dir = 0;
  while (1) {
    if (!dir) {
      mov0(dir, x, y, cl);
      cur += cl;
      if (as.count(pair<long long, long long>(x - y, dir))) return;
      line[dir].push_back(
          pair<pair<long long, long long>, pair<long long, long long> >(
              pair<long long, long long>(x - y, cur),
              pair<long long, long long>(x, y)));
      as.insert(pair<long long, long long>(x - y, dir));
    } else {
      mov1(dir, x, y, cl);
      cur += cl;
      if (as.count(pair<long long, long long>(x + y, dir))) return;
      line[dir].push_back(
          pair<pair<long long, long long>, pair<long long, long long> >(
              pair<long long, long long>(x + y, cur),
              pair<long long, long long>(x, y)));
      as.insert(pair<long long, long long>(x + y, dir));
    }
    if (x == m && y == n) continue;
    if (x == 0 && y == 0) continue;
    if (x == m && y == 0) continue;
    if (x == 0 && y == n) continue;
    dir ^= 1;
  }
}
long long get0(
    pair<pair<long long, long long>, pair<long long, long long> > cur) {
  if (cur.first.first != ix - iy) return 4611686018427387904;
  if (cur.second.first == 0 || cur.second.second == 0)
    return cur.first.second - (ix - cur.second.first);
  else
    return cur.first.second - (cur.second.first - ix);
}
long long get1(
    pair<pair<long long, long long>, pair<long long, long long> > cur) {
  if (cur.first.first != ix + iy) return 4611686018427387904;
  if (cur.second.second == 0 || cur.second.first == m)
    return cur.first.second - (iy - cur.second.second);
  else
    return cur.first.second - (ix - cur.second.first);
}
int main() {
  cin >> m >> n >> k;
  running();
  sort(line[0].begin(), line[0].end());
  sort(line[1].begin(), line[1].end());
  for (long long i = 1; i <= k; ++i) {
    cin >> ix >> iy;
    long long foo =
        lower_bound(
            line[0].begin(), line[0].end(),
            pair<pair<long long, long long>, pair<long long, long long> >(
                pair<long long, long long>(ix - iy, 0),
                pair<long long, long long>(0, 0))) -
        line[0].begin();
    long long bar =
        lower_bound(
            line[1].begin(), line[1].end(),
            pair<pair<long long, long long>, pair<long long, long long> >(
                pair<long long, long long>(ix + iy, 0),
                pair<long long, long long>(0, 0))) -
        line[1].begin();
    long long res0 =
        (foo < line[0].size() ? get0(line[0][foo]) : 4611686018427387904);
    long long res1 =
        (bar < line[1].size() ? get1(line[1][bar]) : 4611686018427387904);
    long long ans = min(res1, res0);
    printf("%I64d\n", (ans != 4611686018427387904 ? ans : -1));
  }
  return 0;
}
