#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
struct Point {
  int x, y;
  Point() { x = y = 0; }
  Point(int _x, int _y) {
    x = _x;
    y = _y;
  }
  Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); }
  Point operator*(int k) const { return (Point(x * k, y * k)); }
};
map<int, set<int> > pointAdd, pointSub;
Point points[200200];
long long answer[200200];
int n, limX, limY;
void init(void) {
  scanf("%d%d%d", &limX, &limY, &n);
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    scanf("%d%d", &points[i].x, &points[i].y);
  for (int i = (1), _b = (n); i <= _b; i = i + 1) {
    pointAdd[points[i].x + points[i].y].insert(i);
    pointSub[points[i].x - points[i].y].insert(i);
  }
  for (int i = (1), _b = (n); i <= _b; i = i + 1) answer[i] = -1;
}
void removePoint(Point pos, Point dir, long long curTime) {
  set<int> &pass =
      dir.x * dir.y < 0 ? pointAdd[pos.x + pos.y] : pointSub[pos.x - pos.y];
  while (!pass.empty()) {
    int id = *pass.begin();
    answer[id] = curTime + (points[id].x - pos.x) / dir.x;
    pointAdd[points[id].x + points[id].y].erase(id);
    pointSub[points[id].x - points[id].y].erase(id);
  }
}
bool inside(Point p) {
  return 0 <= p.x && p.x <= limX && 0 <= p.y && p.y <= limY;
}
Point getNextPos(Point pos, Point dir) {
  int L = 0;
  int R = 200200;
  while (true) {
    if (L == R) return (pos + dir * R);
    if (R - L == 1)
      return (inside(pos + dir * R) ? pos + dir * R : pos + dir * L);
    int M = (L + R) >> 1;
    if (inside(pos + dir * M))
      L = M;
    else
      R = M - 1;
  }
}
bool isCorner(Point p) {
  if (0 < p.x && p.x < limX) return false;
  if (0 < p.y && p.y < limY) return false;
  return true;
}
Point getNextDir(Point dir, Point nextPos) {
  if (nextPos.x == 0 || nextPos.x == limX) return Point(-dir.x, dir.y);
  if (nextPos.y == 0 || nextPos.y == limY) return Point(dir.x, -dir.y);
  assert(false);
}
void process(void) {
  Point pos(0, 0);
  Point dir(1, 1);
  long long curTime = 0;
  while (true) {
    removePoint(pos, dir, curTime);
    Point nextPos = getNextPos(pos, dir);
    if (isCorner(nextPos)) break;
    Point nextDir = getNextDir(dir, nextPos);
    long long nextTime = curTime + (nextPos.x - pos.x) / dir.x;
    pos = nextPos;
    dir = nextDir;
    curTime = nextTime;
  }
  for (int i = (1), _b = (n); i <= _b; i = i + 1) cout << answer[i] << "\n";
}
int main(void) {
  init();
  process();
  return 0;
}
