#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long vis[4][maxn * 2];
int n, m;
long long solve(int x, int y) {
  long long ans = 1e11;
  if (vis[0][x - y + maxn] != -1) {
    long long tmp = vis[0][x - y + maxn];
    if (x - y > 0)
      tmp += y;
    else
      tmp += x;
    ans = min(ans, tmp);
  }
  if (vis[2][x - y + maxn] != -1) {
    long long tmp = vis[2][x - y + maxn];
    if (x - y < n - m)
      tmp += m - y;
    else
      tmp += n - x;
    ans = min(ans, tmp);
  }
  if (vis[1][x + y] != -1) {
    long long tmp = vis[1][x + y];
    if (x + y < n)
      tmp += y;
    else
      tmp += n - x;
    ans = min(ans, tmp);
  }
  if (vis[3][x + y] != -1) {
    long long tmp = vis[3][x + y];
    if (x + y < m)
      tmp += x;
    else
      tmp += m - y;
    ans = min(ans, tmp);
  }
  if (ans != 1e11) return ans;
  return -1;
}
int main() {
  int k;
  scanf("%d%d%d", &n, &m, &k);
  long long dir = 1, cx = 0, cy = 0, ct = 0;
  memset(vis, -1, sizeof(vis));
  while (true) {
    if (dir == 1) {
      vis[dir - 1][cx - cy + maxn] = ct;
      long long tmp = min(n - cx, m - cy);
      cx += tmp;
      cy += tmp;
      ct += tmp;
      if (cx == n && cy == m)
        break;
      else if (cx == n)
        dir = 2;
      else if (cy == m)
        dir = 4;
    } else if (dir == 2) {
      vis[dir - 1][cy + cx] = ct;
      long long tmp = min(cx, m - cy);
      cx -= tmp;
      cy += tmp;
      ct += tmp;
      if (cx == 0 && cy == m)
        break;
      else if (cx == 0)
        dir = 1;
      else if (cy == m)
        dir = 3;
    } else if (dir == 3) {
      vis[dir - 1][cx - cy + maxn] = ct;
      long long tmp = min(cx, cy);
      cx -= tmp;
      cy -= tmp;
      ct += tmp;
      if (cx == 0 && cy == 0)
        break;
      else if (cx == 0)
        dir = 4;
      else if (cy == 0)
        dir = 2;
    } else if (dir == 4) {
      vis[dir - 1][cy + cx] = ct;
      long long tmp = min(n - cx, cy);
      cx += tmp;
      cy -= tmp;
      ct += tmp;
      if (cx == n && cy == 0)
        break;
      else if (cx == n)
        dir = 3;
      else if (cy == 0)
        dir = 1;
    }
  }
  while (k--) {
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%lld\n", solve(x, y));
  }
  return 0;
}
