#include <bits/stdc++.h>
using namespace std;
const int C = 1e5;
pair<int64_t, int64_t> f1[200005], f2[200005];
int m, n, T;
bool F1[100005][4], F2[100005][4];
void DFS(int u, int v, int dir, int64_t time) {
  if (v == 0 || v == n) {
    if (F1[u][dir] == true) return;
    F1[u][dir] = true;
  }
  if (u == 0 || u == m) {
    if (F2[v][dir] == true) return;
    F2[v][dir] = true;
  }
  if ((dir == 0 || dir == 2) && f1[u - v + C] == pair<int64_t, int64_t>(-1, -1))
    f1[u - v + C] = pair<int64_t, int64_t>(u, time);
  else if ((dir == 1 || dir == 3) &&
           f2[u + v] == pair<int64_t, int64_t>(-1, -1))
    f2[u + v] = pair<int64_t, int64_t>(u, time);
  if (dir == 0) {
    int tmp = min(m - u, n - v);
    u += tmp;
    v += tmp;
    if ((u == 0 && v == 0) || (u == m && v == 0) || (u == 0 && v == n) ||
        (u == m && v == n))
      return;
    if (m - u <= n - v)
      DFS(u, v, 1, time + tmp);
    else
      DFS(u, v, 3, time + tmp);
  }
  if (dir == 1) {
    int tmp = min(u, n - v);
    u -= tmp;
    v += tmp;
    if ((u == 0 && v == 0) || (u == m && v == 0) || (u == 0 && v == n) ||
        (u == m && v == n))
      return;
    if (u <= n - v)
      DFS(u, v, 0, time + tmp);
    else
      DFS(u, v, 2, time + tmp);
  }
  if (dir == 2) {
    int tmp = min(u, v);
    u -= tmp;
    v -= tmp;
    if ((u == 0 && v == 0) || (u == m && v == 0) || (u == 0 && v == n) ||
        (u == m && v == n))
      return;
    if (u <= v)
      DFS(u, v, 3, time + tmp);
    else
      DFS(u, v, 1, time + tmp);
  }
  if (dir == 3) {
    int tmp = min(m - u, v);
    u += tmp;
    v -= tmp;
    if ((u == 0 && v == 0) || (u == m && v == 0) || (u == 0 && v == n) ||
        (u == m && v == n))
      return;
    if (m - u <= v)
      DFS(u, v, 2, time + tmp);
    else
      DFS(u, v, 0, time + tmp);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> m >> n >> T;
  for (int i = 0; i <= 2e5; i++) {
    f1[i] = pair<int64_t, int64_t>(-1, -1);
    f2[i] = pair<int64_t, int64_t>(-1, -1);
  }
  DFS(0, 0, 0, 0);
  int u, v;
  while (T--) {
    cin >> u >> v;
    int64_t tmp1 = 1e12, tmp2 = 1e12;
    if (f1[u - v + C] != pair<int64_t, int64_t>(-1, -1))
      tmp1 = abs(f1[u - v + C].second + abs(f1[u - v + C].first - u));
    if (f2[u + v] != pair<int64_t, int64_t>(-1, -1))
      tmp2 = abs(f2[u + v].second + abs(f2[u + v].first - u));
    if (tmp1 == 1e12 && tmp2 == 1e12)
      cout << -1 << "\n";
    else
      cout << min(tmp1, tmp2) << "\n";
  }
}
