#include <bits/stdc++.h>
using namespace std;
long long int curr[400010][4];
int n, m;
int cal(int x, int y) {
  if (x == 0 && y != m)
    return y;
  else if (y == m && x != n)
    return 100001 + x;
  else if (x == n && y != 0)
    return 200002 + y;
  else
    return 300003 + x;
}
int main() {
  int k;
  scanf("%d%d%d", &n, &m, &k);
  memset(curr, -1, sizeof(curr));
  curr[0][0] = 0;
  int x = 0, y = 0, dir = 0;
  int tempnum, tempdir;
  int minn;
  while (1) {
    tempnum = cal(x, y);
    tempdir = dir;
    if (dir == 0) {
      minn = min(n - x, m - y);
      x += minn, y += minn;
      if (x == n)
        dir = 3;
      else
        dir = 1;
    } else if (dir == 1) {
      minn = min(n - x, y);
      x += minn, y -= minn;
      if (x == n)
        dir = 2;
      else
        dir = 0;
    } else if (dir == 2) {
      minn = min(x, y);
      x -= minn, y -= minn;
      if (x == 0)
        dir = 1;
      else
        dir = 3;
    } else {
      minn = min(x, m - y);
      x -= minn, y += minn;
      if (x == 0)
        dir = 0;
      else
        dir = 2;
    }
    if ((x == n || x == 0) && (y == m || y == 0)) break;
    int num = cal(x, y);
    if (curr[num][dir] != -1) break;
    curr[num][dir] = curr[tempnum][tempdir] + minn;
  }
  while (k--) {
    scanf("%d%d", &x, &y);
    long long int minn = -1;
    if (x <= y && curr[cal(0, y - x)][0] != -1) {
      if (minn == -1)
        minn = curr[cal(0, y - x)][0] + (long long int)x;
      else
        minn = min(minn, curr[cal(0, y - x)][0] + (long long int)x);
    }
    if (y + x <= m && curr[cal(0, y + x)][1] != -1) {
      if (minn == -1)
        minn = curr[cal(0, y + x)][1] + (long long int)x;
      else
        minn = min(minn, curr[cal(0, y + x)][1] + (long long int)x);
    }
    if (x >= y && curr[cal(x - y, 0)][0] != -1) {
      if (minn == -1)
        minn = curr[cal(x - y, 0)][0] + (long long int)y;
      else
        minn = min(minn, curr[cal(x - y, 0)][0] + (long long int)y);
    }
    if (y + x <= n && curr[cal(x + y, 0)][3] != -1) {
      if (minn == -1)
        minn = curr[cal(x + y, 0)][3] + (long long int)y;
      else
        minn = min(minn, curr[cal(x + y, 0)][3] + (long long int)y);
    }
    if (x + m - y <= n && curr[cal(x + m - y, m)][2] != -1) {
      if (minn == -1)
        minn = curr[cal(x + m - y, m)][2] + (long long int)(m - y);
      else
        minn = min(minn, curr[cal(x + m - y, m)][2] + (long long int)(m - y));
    }
    if (x - (m - y) >= 0 && curr[cal(x - (m - y), m)][1] != -1) {
      if (minn == -1)
        minn = curr[cal(x - (m - y), m)][1] + (long long int)(m - y);
      else
        minn = min(minn, curr[cal(x - (m - y), m)][1] + (long long int)(m - y));
    }
    if (y - (n - x) >= 0 && curr[cal(n, y - (n - x))][3] != -1) {
      if (minn == -1)
        minn = curr[cal(n, y - (n - x))][3] + (long long int)(n - x);
      else
        minn = min(minn, curr[cal(n, y - (n - x))][3] + (long long int)(n - x));
    }
    if (y + n - x <= m && curr[cal(n, y + n - x)][2] != -1) {
      if (minn == -1)
        minn = curr[cal(n, y + n - x)][2] + (long long int)(n - x);
      else
        minn = min(minn, curr[cal(n, y + n - x)][2] + (long long int)(n - x));
    }
    printf("%I64d\n", minn);
  }
  return 0;
}
