#include <bits/stdc++.h>
using namespace std;
template <int input_buf_size, int output_buf_size>
class FastIO {
  char cbuf[input_buf_size + 1];
  int icur = 0;
  inline bool go_to_next_token() {
    while (cbuf[icur] == ' ' || cbuf[icur] == '\n') icur++;
    while (cbuf[icur] == 0) {
      icur = 0;
      if (fgets(cbuf, sizeof(cbuf), stdin) != cbuf) return false;
      while (cbuf[icur] == ' ' || cbuf[icur] == '\n') icur++;
    }
    return true;
  }

 public:
  string readString() {
    assert(go_to_next_token());
    string ans;
    while (cbuf[icur] != ' ' && cbuf[icur] != '\n' && cbuf[icur] != 0)
      ans.push_back(cbuf[icur++]);
    ans.shrink_to_fit();
    return ans;
  }
  template <class int_type>
  int_type readInt() {
    assert(go_to_next_token());
    int_type x = 0;
    bool m = cbuf[icur] == '-';
    if (m) icur++;
    while ('0' <= cbuf[icur] && cbuf[icur] <= '9') {
      x *= 10;
      x += (cbuf[icur] - '0');
      icur++;
    }
    if (m) x = -x;
    return x;
  }
  bool seekEof() { return !go_to_next_token(); }

 private:
  char obuf[output_buf_size + 1];
  int ocur = 0;
  inline void write_string(const char* str, size_t sz = 0) {
    if (sz == 0) sz = strlen(str);
    if (ocur + sz > output_buf_size) {
      fputs(obuf, stdout);
      fputs(str, stdout);
      ocur = 0;
      obuf[0] = 0;
      return;
    }
    strcpy(obuf + ocur, str);
    ocur += sz;
    obuf[ocur] = 0;
  }

 public:
  template <class int_type>
  void writeInt(int_type x, bool sp = true) {
    char buf[20];
    int c = 0;
    if (x < 0) {
      buf[c++] = '-';
      x = -x;
    }
    int s = c;
    if (x == 0) {
      buf[c++] = '0';
    }
    while (x > 0) {
      buf[c++] = (x % 10) + '0';
      x /= 10;
    }
    for (int i = 0; 2 * i < c - s; i++) {
      swap(buf[s + i], buf[c - 1 - i]);
    }
    buf[c] = 0;
    write_string(buf, c);
    if (sp) write_string(" ", 1);
  }
  void writeString(string s, bool space = true) {
    write_string(s.c_str(), s.size());
    if (space) write_string(" ", 1);
  }
  void writeEndl() { write_string("\n", 1); }
  void flush() {
    fputs(obuf, stdout);
    ocur = 0;
    obuf[0] = 0;
  }

 private:
  bool lflush;

 public:
  FastIO(bool local_flush) {
    obuf[0] = 0;
    lflush = local_flush;
  }
  ~FastIO() { fputs(obuf, stdout); }
};
FastIO<10000000, 10000000> IO(true);
struct pos {
  int x, y;
  int dx, dy;
  pos() {}
  pos(int _x, int _y, int _dx, int _dy) {
    x = _x;
    y = _y;
    dx = _dx;
    dy = _dy;
  }
};
bool operator<(const pos& p1, const pos& p2) {
  return make_tuple(p1.x, p1.y, p1.dx, p1.dy) <
         make_tuple(p2.x, p2.y, p2.dx, p2.dy);
}
int n, m;
pos next(pos a, int& dt) {
  pos ret;
  if (a.y == 0 || a.y == m) {
    if (a.x + a.dx * m <= n && a.x + a.dx * m >= 0) {
      dt = m;
    } else if (a.x + a.dx * m > n) {
      dt = n - a.x;
    } else {
      dt = a.x;
    }
  } else {
    if (a.y + a.dy * n <= m && a.y + a.dy * n >= 0) {
      dt = n;
    } else if (a.y + a.dy * n > m) {
      dt = m - a.y;
    } else {
      dt = a.y;
    }
  }
  ret.x = a.x + a.dx * dt;
  ret.y = a.y + a.dy * dt;
  if (ret.y == m || ret.y == 0) {
    ret.dx = a.dx;
    ret.dy = -a.dy;
  } else {
    ret.dx = -a.dx;
    ret.dy = a.dy;
  }
  return ret;
}
bool is_end(pos a) {
  return (a.x == 0 && a.y == 0) || (a.x == n && a.y == m) ||
         (a.x == n && a.y == 0) || (a.x == 0 && a.y == m);
}
int main() {
  int k;
  n = IO.readInt<int>();
  m = IO.readInt<int>();
  k = IO.readInt<int>();
  int x[k], y[k];
  for (int i = 0; i < k; i++) {
    x[i] = IO.readInt<int>();
    y[i] = IO.readInt<int>();
  }
  map<pos, vector<pair<int, int> > > in_pos;
  int dt;
  for (int i = 0; i < k; i++) {
    int ta = min(x[i], y[i]);
    pos a(x[i] - ta, y[i] - ta, 1, 1);
    int tb = min(n - x[i], y[i]);
    pos b(x[i] + tb, y[i] - tb, -1, 1);
    int tc = min(n - x[i], m - y[i]);
    pos c(x[i] + tc, y[i] + tc, -1, -1);
    int td = min(x[i], m - y[i]);
    pos d(x[i] - td, y[i] + td, 1, -1);
    in_pos[a].push_back(make_pair(i, ta));
    in_pos[b].push_back(make_pair(i, tb));
    in_pos[c].push_back(make_pair(i, tc));
    in_pos[d].push_back(make_pair(i, td));
  }
  long long ans[k];
  for (int i = 0; i < k; i++) ans[i] = 1791791791791791791ll;
  pos cur(0, 0, 1, 1);
  long long t = 0;
  do {
    for (auto u : in_pos[cur]) ans[u.first] = min(ans[u.first], t + u.second);
    cur = next(cur, dt);
    t += dt;
  } while (!is_end(cur));
  for (int i = 0; i < k; i++) {
    if (ans[i] > (n + 1) * 1ll * (m + 1))
      IO.writeInt(-1);
    else
      IO.writeInt(ans[i]);
    IO.writeEndl();
  }
  return 0;
}
