#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 5;
set<pair<int, int> > curr, vis;
map<pair<int, int>, int> idx;
map<int, set<int> > M[2];
set<int>::iterator it;
long long ans[N];
int n, m, k;
int main() {
  int x, y;
  scanf("%d %d %d", &n, &m, &k);
  int i;
  for (i = 1; i <= k; i++) {
    ans[i] = -1;
    scanf("%d %d", &x, &y);
    curr.insert(make_pair(x, y));
    idx[make_pair(x, y)] = i;
    M[0][x + y].insert(x);
    M[1][x - y].insert(x);
  }
  int cx = 0, cy = 0, fx = 1, fy = 1, nx, ny, cnt, l;
  long long sum = 0;
  vis.insert(make_pair(0, 0));
  while (1) {
    if (fx == 1) {
      cnt = n - cx;
    } else {
      cnt = cx;
    }
    if (fy == 1) {
      cnt = min(cnt, m - cy);
    } else {
      cnt = min(cnt, cy);
    }
    nx = cx + cnt * fx;
    ny = cy + cnt * fy;
    vector<pair<int, int> > query;
    if (abs(fx + fy) == 2) {
      it = M[1][cx - cy].lower_bound(min(nx, cx));
      while (it != M[1][cx - cy].end()) {
        l = *it;
        if (l <= max(nx, cx)) {
          query.push_back(make_pair(l, l - (cx - cy)));
          ans[idx[make_pair(l, l - (cx - cy))]] = sum + abs(l - cx);
          it++;
        } else {
          break;
        }
      }
    } else {
      it = M[0][cx + cy].lower_bound(min(nx, cx));
      while (it != M[0][cx + cy].end()) {
        l = *it;
        if (l <= max(nx, cx)) {
          ans[idx[make_pair(l, cx + cy - l)]] = sum + abs(l - cx);
          query.push_back(make_pair(l, cx + cy - l));
          it++;
        } else {
          break;
        }
      }
    }
    for (i = 0; i < (int(query.size())); i++) {
      x = query[i].first;
      y = query[i].second;
      M[0][x + y].erase(x);
      M[1][x - y].erase(x);
    }
    if (nx == 0) {
      fx = 1;
    }
    if (nx == n) {
      fx = -1;
    }
    if (ny == 0) {
      fy = 1;
    }
    if (ny == m) {
      fy = -1;
    }
    sum += cnt;
    cx = nx;
    cy = ny;
    if (vis.find(make_pair(cx, cy)) != vis.end()) {
      break;
    }
    if (((cx == 0) || (cx == n)) && ((cy == 0) || (cy == m))) {
      break;
    }
    vis.insert(make_pair(cx, cy));
  }
  for (i = 1; i <= k; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
