#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
struct node {
  int x;
  int y;
  int tzz;
  int num;
} mt_plus[maxn + 7], mt_minus[maxn + 7];
long long times[maxn];
void qs(node a[], int l, int r) {
  if (l >= r) return;
  int i = l, j = r, key = a[l + rand() % (r - l + 1)].tzz;
  while (i < j) {
    while (a[i].tzz < key) i++;
    while (a[j].tzz > key) j--;
    if (i <= j) {
      node t = a[i];
      a[i] = a[j];
      a[j] = t;
      ++i;
      --j;
    }
  }
  qs(a, i, r);
  qs(a, l, j);
}
int left_side(node a[], int x, int l, int r) {
  if (l == r) return l;
  int mid = (l + r) / 2;
  if (a[mid].tzz >= x) {
    return left_side(a, x, l, mid);
  } else {
    return left_side(a, x, mid + 1, r);
  }
}
int right_side(node a[], int x, int l, int r) {
  if (l == r) return l;
  int mid = (l + r) / 2;
  if (a[mid].tzz <= x) {
    return right_side(a, x, mid + 1, r);
  } else {
    return right_side(a, x, l, mid);
  }
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; ++i) {
    scanf("%d%d", &mt_plus[i].x, &mt_plus[i].y);
    mt_minus[i].x = mt_plus[i].x;
    mt_minus[i].y = mt_plus[i].y;
    mt_plus[i].num = i;
    mt_minus[i].num = i;
    mt_plus[i].tzz = mt_plus[i].x + mt_plus[i].y;
    mt_minus[i].tzz = mt_minus[i].y - mt_minus[i].x;
  }
  qs(mt_plus, 1, k);
  qs(mt_minus, 1, k);
  memset(times, 0, sizeof(times));
  int dir = 0;
  int defx = 0, defy = 0;
  bool flag = true;
  long long tc = 0;
  while (true) {
    int l, r;
    if (dir <= 1) {
      l = left_side(mt_minus, defy - defx, 1, k);
      r = right_side(mt_minus, defy - defx, 1, k);
      for (int i = l; i <= r; ++i) {
        if (times[mt_minus[i].num] == 0 && mt_minus[i].tzz == defy - defx)
          times[mt_minus[i].num] = tc + abs(mt_minus[i].x - defx);
      }
      if (dir == 0) {
        if (n - defx == m - defy) {
          flag = false;
        } else {
          if (n - defx < m - defy) {
            dir = 2;
            tc += n - defx;
            defy = n - defx + defy;
            defx = n;
          } else {
            dir = 3;
            tc += m - defy;
            defx = m + defx - defy;
            defy = m;
          }
        }
      } else {
        if (defx == defy) {
          flag = false;
        } else {
          if (defx < defy) {
            dir = 3;
            tc += defx;
            defy = defy - defx;
            defx = 0;
          } else {
            dir = 2;
            tc += defy;
            defx = defx - defy;
            defy = 0;
          }
        }
      }
    } else {
      l = left_side(mt_plus, defy + defx, 1, k);
      r = right_side(mt_plus, defy + defx, 1, k);
      for (int i = l; i <= r; ++i) {
        if (times[mt_plus[i].num] == 0) {
          if (mt_plus[i].tzz == defy + defx) {
            times[mt_plus[i].num] = tc + abs(mt_plus[i].x - defx);
          }
        }
      }
      if (dir == 2) {
        if (m == defx + defy) {
          flag = false;
        } else {
          if (m < defx + defy) {
            dir = 1;
            tc += m - defy;
            defx = defx + defy - m;
            defy = m;
          } else {
            dir = 0;
            tc += defx;
            defy = defx + defy;
            defx = 0;
          }
        }
      } else {
        if (n == defx + defy) {
          flag = false;
        } else {
          if (n > defx + defy) {
            dir = 0;
            tc += defy;
            defx = defx + defy;
            defy = 0;
          } else {
            dir = 1;
            tc += n - defx;
            defy = defx + defy - n;
            defx = n;
          }
        }
      }
    }
    if (!flag) break;
  }
  for (int i = 1; i <= k; ++i) {
    if (times[i]) {
      cout << times[i] << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
