#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e+5 + 100;
int n, m, k;
int get_rd(int i, int j) {
  if (i == j) {
    return n;
  } else if (i < j) {
    return n + (j - i);
  } else {
    return n - (i - j);
  }
}
int get_ld(int i, int j) {
  if (i + j == n) {
    return n;
  } else if (i + j < n) {
    return i + j;
  } else {
    return i + j;
  }
}
struct detector {
  int i, j, id;
  detector(int i, int j, int id) : i(i), j(j), id(id) {}
  int get_rd() { return ::get_rd(i, j); }
  int get_ld() { return ::get_ld(i, j); }
};
vector<bool> used(LIM, false);
vector<long long> ans(LIM, -1);
vector<vector<detector>> ld(2 * LIM);
vector<vector<detector>> rd(2 * LIM);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    int pi, pj;
    cin >> pi >> pj;
    detector newbie(pi, pj, i);
    rd[newbie.get_rd()].push_back(newbie);
    ld[newbie.get_ld()].push_back(newbie);
  }
  int i = 0, j = 0;
  int di = 1, dj = 1;
  long long time = 0;
  while (true) {
    int d = -1;
    if (di == dj) {
      d = get_rd(i, j);
      for (const detector& det : rd[d]) {
        int id = det.id;
        if (!used[id]) {
          ans[id] = time + abs(i - det.i);
          used[id] = true;
        }
      }
    } else {
      d = get_ld(i, j);
      for (const detector& det : ld[d]) {
        int id = det.id;
        if (!used[id]) {
          ans[id] = time + abs(i - det.i);
          used[id] = true;
        }
      }
    }
    if (di == 1 && dj == 1) {
      int delta = min(n - i, m - j);
      time += delta;
      i += delta;
      j += delta;
      if (i == n && j == m) {
        break;
      }
      if (i == n)
        di = -1;
      else
        dj = -1;
    } else if (di == -1 && dj == -1) {
      int delta = min(i, j);
      time += delta;
      i -= delta;
      j -= delta;
      if (i == 0 && j == 0) break;
      if (i == 0)
        di = 1;
      else
        dj = 1;
    } else if (di == 1 && dj == -1) {
      int delta = min(n - i, j);
      time += delta;
      i += delta;
      j -= delta;
      if (i == n && j == 0) break;
      if (i == n)
        di = -1;
      else
        dj = 1;
    } else {
      int delta = min(i, m - j);
      time += delta;
      i -= delta;
      j += delta;
      if (i == 0 && j == m) break;
      if (i == 0)
        di = 1;
      else
        dj = -1;
    }
  }
  for (int i = 0; i < k; ++i) cout << ans[i] << '\n';
  return 0;
}
