#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  vector<vector<int>> sum_points(n + m), diff_points(n + m);
  vector<int> x(k), y(k);
  for (int i = 0; i < k; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    sum_points[x[i] + y[i]].push_back(i);
    diff_points[x[i] - y[i] + m].push_back(i);
  }
  vector<long long> ans(k, -1);
  long long time = 0;
  int px = 0, py = 0, nx = 0, ny = 0;
  int dx = 1, dy = 1;
  while (dx) {
    int xdiff = (dx > 0) ? n - px : px;
    int ydiff = (dy > 0) ? m - py : py;
    int diff = min(xdiff, ydiff);
    nx = px + diff * dx;
    ny = py + diff * dy;
    if (dx * dy > 0) {
      for (int i : diff_points[nx - ny + m])
        if (ans[i] == -1) ans[i] = time + abs(x[i] - px);
    } else {
      for (int i : sum_points[nx + ny])
        if (ans[i] == -1) ans[i] = time + abs(x[i] - px);
    }
    if (xdiff < ydiff) dx *= -1;
    if (xdiff > ydiff) dy *= -1;
    if (xdiff == ydiff) dx = 0;
    px = nx;
    py = ny;
    time += diff;
  }
  for (long long t : ans) printf("%lld\n", t);
  return 0;
}
