#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX / 3ll;
int n, m;
map<pair<pair<int, int>, int>, long long> marca;
pair<pair<int, int>, int> temp;
int dx, dy;
void doSimulation(int x, int y, int dir, long long t) {
  temp.first.first = x;
  temp.first.second = y;
  temp.second = dir;
  if (marca.count(temp)) return;
  marca[temp] = t;
  if (t && x == 0 && (y == 0 || y == m)) return;
  if (x == n && (y == 0 || y == m)) return;
  if (dir == 0) {
    dx = n - x;
    dy = m - y;
    if (dx < dy)
      doSimulation(x + dx, y + dx, 3, t + dx);
    else
      doSimulation(x + dy, y + dy, 1, t + dy);
  }
  if (dir == 1) {
    dx = n - x;
    dy = y;
    if (dx < dy)
      doSimulation(x + dx, y - dx, 2, t + dx);
    else
      doSimulation(x + dy, y - dy, 0, t + dy);
  }
  if (dir == 2) {
    dx = x;
    dy = y;
    if (dx < dy)
      doSimulation(x - dx, y - dx, 1, t + dx);
    else
      doSimulation(x - dy, y - dy, 3, t + dy);
  }
  if (dir == 3) {
    dx = x;
    dy = m - y;
    if (dx < dy)
      doSimulation(x - dx, y + dx, 0, t + dx);
    else
      doSimulation(x - dy, y + dy, 2, t + dy);
  }
}
long long get(int x, int y, int dir) {
  temp.first = make_pair(x, y);
  temp.second = dir;
  if (marca.count(temp)) return marca[temp];
  return INF;
}
long long calc(int x, int y) {
  long long ans = INF;
  dx = x;
  dy = y;
  if (dx < dy)
    ans = min(ans, get(x - dx, y - dx, 0) + dx);
  else
    ans = min(ans, get(x - dy, y - dy, 0) + dy);
  dx = x;
  dy = m - y;
  if (dx < dy)
    ans = min(ans, get(x - dx, y + dx, 1) + dx);
  else
    ans = min(ans, get(x - dy, y + dy, 1) + dy);
  dx = n - x;
  dy = m - y;
  if (dx < dy)
    ans = min(ans, get(x + dx, y + dx, 2) + dx);
  else
    ans = min(ans, get(x + dy, y + dy, 2) + dy);
  dx = n - x;
  dy = y;
  if (dx < dy)
    ans = min(ans, get(x + dx, y - dx, 3) + dx);
  else
    ans = min(ans, get(x + dy, y - dy, 3) + dy);
  if (ans >= INF) return -1;
  return ans;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int k, x, y;
  cin >> n >> m;
  cin >> k;
  doSimulation(0, 0, 0, 0);
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    cout << calc(x, y) << '\n';
  }
  return 0;
}
