#include <bits/stdc++.h>
struct node {
  int x, y, id;
};
int n, m, k;
long long ans[(100010)];
std::map<int, std::vector<struct node> > sub;
std::map<int, std::vector<struct node> > pls;
void update(int id, long long x) {
  if (ans[id] == 0)
    ans[id] = x;
  else
    ans[id] = std::min(ans[id], x);
}
void dfs(int x, int y, int dir, long long now) {
  if ((x == 0 && y == m) || (x == n && y == 0) || (x == n && y == m)) {
    return;
  }
  int tx, ty;
  long long len, tmp;
  if (dir == 0) {
    if (n - x <= m - y) {
      tx = n;
      ty = y + n - x;
      dir = 3;
      len = n - x;
    } else {
      tx = x + m - y;
      ty = m;
      dir = 1;
      len = m - y;
    }
    if (!sub[x - y].empty()) {
      for (auto u : sub[x - y]) {
        tmp = now + u.x - x;
        update(u.id, tmp);
      }
    }
  } else if (dir == 1) {
    if (n - x <= y) {
      tx = n;
      ty = y - n + x;
      dir = 2;
      len = n - x;
    } else {
      tx = x + y;
      ty = 0;
      dir = 0;
      len = y;
    }
    if (!pls[x + y].empty()) {
      for (auto u : pls[x + y]) {
        tmp = now + u.x - x;
        update(u.id, tmp);
      }
    }
  } else if (dir == 2) {
    if (x <= y) {
      tx = 0;
      ty = y - x;
      dir = 1;
      len = x;
    } else {
      tx = x - y;
      ty = 0;
      dir = 3;
      len = y;
    }
    if (!sub[x - y].empty()) {
      for (auto u : sub[x - y]) {
        tmp = now + x - u.x;
        update(u.id, tmp);
      }
    }
  } else {
    if (x <= m - y) {
      tx = 0;
      ty = y + x;
      dir = 0;
      len = x;
    } else {
      tx = x - m + y;
      ty = m;
      dir = 2;
      len = m - y;
    }
    if (!pls[x + y].empty()) {
      for (auto u : pls[x + y]) {
        tmp = now + x - u.x;
        update(u.id, tmp);
      }
    }
  }
  dfs(tx, ty, dir, now + len);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    sub[x - y].push_back((node){x, y, i});
    pls[x + y].push_back((node){x, y, i});
  }
  dfs(0, 0, 0, 0);
  for (int i = 1; i <= k; ++i) {
    printf("%I64d\n", ans[i] ? ans[i] : -1);
  }
  return 0;
}
