#include <bits/stdc++.h>
using namespace std;
long long ans[100000];
long long a[100000][2];
long long n, m;
int k;
vector<int> dig1[300000];
vector<int> dig2[300000];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  int mm = max(n, m);
  for (int i = 0; i < k; i++) {
    cin >> a[i][0] >> a[i][1];
    dig1[a[i][0] + a[i][1]].push_back(i);
    dig2[a[i][0] - a[i][1] + mm].push_back(i);
    ans[i] = -1;
  }
  long long x = 0;
  long long y = 0;
  int dir = 0;
  long long t = 0;
  while (true) {
    if (dir == 0) {
      long long d1 = n - x;
      long long d2 = m - y;
      long long dd = min(d1, d2);
      int dig = x - y + mm;
      for (int p : dig2[dig]) {
        if (ans[p] != -1) continue;
        ans[p] = a[p][1] - y + t;
      }
      t += dd;
      x += dd;
      y += dd;
      if (x == n) dir = 1;
      if (y == m) dir = 3;
    } else if (dir == 1) {
      long long d1 = x;
      long long d2 = m - y;
      long long dd = min(d1, d2);
      int dig = x + y;
      for (int p : dig1[dig]) {
        if (ans[p] != -1) continue;
        ans[p] = a[p][1] - y + t;
      }
      t += dd;
      x -= dd;
      y += dd;
      if (x == 0) dir = 0;
      if (y == m) dir = 2;
    } else if (dir == 2) {
      long long d1 = x;
      long long d2 = y;
      long long dd = min(d1, d2);
      int dig = x - y + mm;
      for (int p : dig2[dig]) {
        if (ans[p] != -1) continue;
        ans[p] = y - a[p][1] + t;
      }
      t += dd;
      x -= dd;
      y -= dd;
      if (x == 0) dir = 3;
      if (y == 0) dir = 1;
    } else if (dir == 3) {
      long long d1 = n - x;
      long long d2 = y;
      long long dd = min(d1, d2);
      int dig = x + y;
      for (int p : dig1[dig]) {
        if (ans[p] != -1) continue;
        ans[p] = y - a[p][1] + t;
      }
      t += dd;
      x += dd;
      y -= dd;
      if (x == n) dir = 2;
      if (y == 0) dir = 0;
    }
    if (x == 0 && y == 0) break;
    if (x == n && y == 0) break;
    if (x == 0 && y == m) break;
    if (x == n && y == m) break;
  }
  for (int i = 0; i < k; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
