#include <bits/stdc++.h>
using namespace std;
vector<int> M1[300000];
vector<int> M2[300000];
vector<pair<int, int>> p;
vector<long long> ans;
int dist(int x, int y, int xx, int yy) { return abs(x - xx); }
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    M1[x + y].push_back(i);
    M2[x - y + 130000].push_back(i);
    p.emplace_back(x, y);
  }
  ans.resize(k, -1);
  long long time = 0;
  int x = 0, y = 0;
  int dir = 0;
  while (true) {
    if (dir == 0 || dir == 3) {
      for (int i : M2[x - y + 130000]) {
        if (ans[i] != -1) continue;
        ans[i] = time + dist(x, y, p[i].first, p[i].second);
      }
    } else {
      for (int i : M1[x + y]) {
        if (ans[i] != -1) continue;
        ans[i] = time + dist(x, y, p[i].first, p[i].second);
      }
    }
    long long tmp;
    if (dir == 0) {
      tmp = min(m - y, n - x);
      x += tmp, y += tmp;
      if (m - y < n - x)
        dir = 1;
      else
        dir = 2;
    } else if (dir == 1) {
      tmp = min(y, n - x);
      x += tmp, y -= tmp;
      if (y < n - x)
        dir = 0;
      else
        dir = 3;
    } else if (dir == 2) {
      tmp = min(m - y, x);
      x -= tmp, y += tmp;
      if (m - y < x)
        dir = 3;
      else
        dir = 0;
    } else if (dir == 3) {
      tmp = min(y, x);
      x -= tmp, y -= tmp;
      if (y < x)
        dir = 2;
      else
        dir = 1;
    }
    time += tmp;
    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++) printf("%lld\n", ans[i]);
}
