#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int fx[4][2] = {{-1, 1}, {1, 1}, {1, -1}, {-1, -1}};
int n, m, k;
int vis[N * 4][4];
long long dis[N];
struct node {
  int steps, id;
  node() {}
  node(int _steps, int _id) {
    steps = _steps;
    id = _id;
  }
};
vector<node> G[N * 4][4];
int get(int x, int y) {
  if (x == 0 && y == 0) return -1;
  if (x == n && y == 0) return -1;
  if (x == n && y == m) return -1;
  if (x == 0 && y == m) return -1;
  if (y == 0) return x;
  if (x == n) return n + y;
  if (y == m) return n + m + n - x;
  if (x == 0) return n + m + n + m - y;
}
int reflect(int x, int y, int dir) {
  if (dir == 0) {
    if (x == 0) return 1;
    if (y == m) return 3;
  }
  if (dir == 1) {
    if (x == n) return 0;
    if (y == m) return 2;
  }
  if (dir == 2) {
    if (x == n) return 3;
    if (y == 0) return 1;
  }
  if (dir == 3) {
    if (x == 0) return 2;
    if (y == 0) return 0;
  }
  return -1;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    for (int j = 0; j < 4; j++) {
      int xx, yy;
      int stepx, stepy, step;
      if (fx[j][0] < 0)
        stepx = x;
      else
        stepx = n - x;
      if (fx[j][1] < 0)
        stepy = y;
      else
        stepy = m - y;
      step = min(stepx, stepy);
      xx = x + fx[j][0] * step;
      yy = y + fx[j][1] * step;
      int id = get(xx, yy);
      if (id != -1) {
        G[id][(j + 2) % 4].push_back(node(step, i));
      }
      if (xx == 0 && yy == 0) {
        G[0][(j + 2) % 4].push_back(node(step, i));
      }
    }
  }
  memset(vis, 0, sizeof(vis));
  memset(dis, -1, sizeof(dis));
  int x = 0, y = 0, dir = 1;
  long long Cur = 0;
  while (1) {
    int id = get(x, y);
    if (x == 0 && y == 0) id = 0;
    for (int i = 0; i < G[id][dir].size(); i++) {
      int y = G[id][dir][i].id;
      if (dis[y] == -1) {
        dis[y] = Cur + G[id][dir][i].steps;
      }
    }
    int xx, yy;
    int stepx, stepy, step;
    if (fx[dir][0] < 0)
      stepx = x;
    else
      stepx = n - x;
    if (fx[dir][1] < 0)
      stepy = y;
    else
      stepy = m - y;
    step = min(stepx, stepy);
    xx = x + fx[dir][0] * step;
    yy = y + fx[dir][1] * step;
    Cur += step;
    x = xx;
    y = yy;
    dir = reflect(x, y, dir);
    if (get(x, y) == -1) break;
    if (vis[get(x, y)][dir]) break;
    vis[get(x, y)][dir] = 1;
  }
  for (int i = 1; i <= k; i++) cout << dis[i] << endl;
  return 0;
}
