#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, long long> ans;
int n, m, k;
pair<int, int> getNextPoint(const int& x, const int& y, const int& vx,
                            const int& vy) {
  int l = 0, r = min(n, m) + 1;
  while (l + 1 < r) {
    int c = (l + r) / 2;
    int nx = x + vx * c;
    int ny = y + vy * c;
    if (nx <= 0 || nx >= n || ny <= 0 || ny >= m) {
      r = c;
    } else {
      l = c;
    }
  }
  return {x + vx * r, y + vy * r};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  long long time = 0;
  const pair<int, int> corners[] = {{0, 0}, {n, m}, {0, m}, {n, 0}};
  ans[{0, 0}] = 0;
  int vx = 1, vy = 1, x = 0, y = 0;
  while (true) {
    auto p = getNextPoint(x, y, vx, vy);
    if (ans.count(p) > 0) {
      break;
    }
    if (p == corners[0] || p == corners[1] || p == corners[2] ||
        p == corners[3]) {
      break;
    }
    int dt = abs(x - p.first);
    time = time + dt;
    ans[p] = time;
    if (p.first == 0 || p.first == n) {
      vx *= -1;
    } else {
      vy *= -1;
    }
    x = p.first;
    y = p.second;
  }
  const int dx[] = {1, 1, -1, -1};
  const int dy[] = {1, -1, 1, -1};
  while (k--) {
    int x, y;
    cin >> x >> y;
    long long ot = -1;
    for (int i = 0; i < 4; i++) {
      auto p = getNextPoint(x, y, dx[i], dy[i]);
      if (ans.count(p) > 0) {
        long long d = ans[p];
        if (ot == -1 || ot > d + abs(x - p.first)) {
          ot = d + abs(x - p.first);
        }
      }
    }
    cout << ot << '\n';
  }
  return 0;
}
