#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int wall(int x, int y) {
  if (y == 0)
    return 0;
  else if (x == n)
    return 1;
  else if (y == m)
    return 2;
  else if (x == 0)
    return 3;
  else
    return -1;
}
bool corner(int x, int y) { return (x == 0 || x == n) && (y == 0 || y == m); }
vector<long long> ans;
map<int, vector<pair<pair<int, int>, int>>> pnt[2];
long long counter;
void go(int &x, int &y, int &t) {
  if (t == 0) {
    int take = min(n - x, m - y);
    while (!pnt[t % 2].empty() && pnt[t % 2].count(y - x) &&
           !pnt[t % 2][y - x].empty()) {
      pair<pair<int, int>, int> back = pnt[t % 2][y - x].back();
      pnt[t % 2][y - x].pop_back();
      int need = x - back.first.first;
      need = -need;
      ans[back.second] = min(ans[back.second], counter + need);
    }
    x += take;
    y += take;
    counter += take;
  } else if (t == 1) {
    int take = min(x, m - y);
    while (!pnt[t % 2].empty() && pnt[t % 2].count(x + y) &&
           !pnt[t % 2][x + y].empty()) {
      pair<pair<int, int>, int> back = pnt[t % 2][x + y].back();
      pnt[t % 2][x + y].pop_back();
      int need = back.first.first - x;
      need = -need;
      ans[back.second] = min(ans[back.second], counter + need);
      assert(need >= 0);
    }
    x -= take;
    y += take;
    counter += take;
  } else if (t == 2) {
    int take = min(x, y);
    while (!pnt[t % 2].empty() && pnt[t % 2].count(y - x) &&
           !pnt[t % 2][y - x].empty()) {
      pair<pair<int, int>, int> back = pnt[t % 2][y - x].back();
      pnt[t % 2][y - x].pop_back();
      int need = back.first.first - x;
      need = -need;
      ans[back.second] = min(ans[back.second], counter + need);
      assert(need >= 0);
    }
    x -= take;
    y -= take;
    counter += take;
  } else if (t == 3) {
    int take = min(n - x, y);
    while (!pnt[t % 2].empty() && pnt[t % 2].count(x + y) &&
           !pnt[t % 2][x + y].empty()) {
      pair<pair<int, int>, int> back = pnt[t % 2][x + y].back();
      pnt[t % 2][x + y].pop_back();
      int need = x - back.first.first;
      need = -need;
      assert(need >= 0);
      ans[back.second] = min(ans[back.second], counter + need);
    }
    x += take;
    y -= take;
    counter += take;
  }
  int w = wall(x, y);
  assert(w != -1);
  if (t == 0) {
    t = w == 1 ? 1 : 3;
  } else if (t == 1) {
    t = w == 2 ? 2 : 0;
  } else if (t == 2) {
    t = w == 3 ? 3 : 1;
  } else if (t == 3) {
    t = w == 0 ? 0 : 2;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> k;
  ans.assign(k, LLONG_MAX);
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    pnt[0][y - x].push_back({{x, y}, i});
    pnt[1][x + y].push_back({{x, y}, i});
  }
  set<pair<pair<int, int>, int>> visit;
  int x = 0, y = 0, t = 0;
  go(x, y, t);
  while (!corner(x, y) && !visit.count(make_pair(pair<int, int>(x, y), t))) {
    visit.insert({{x, y}, t});
    go(x, y, t);
  }
  for (int i = 0; i < k; i++) {
    printf("%lld\n", ans[i] == LLONG_MAX ? -1 : ans[i]);
  }
  return 0;
}
