#include <bits/stdc++.h>
template <typename T>
class IntegerIterator
    : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> {
 public:
  explicit IntegerIterator(T value) : value(value) {}
  IntegerIterator& operator++() {
    ++value;
    return *this;
  }
  IntegerIterator operator++(int) {
    IntegerIterator copy = *this;
    ++value;
    return copy;
  }
  IntegerIterator& operator--() {
    --value;
    return *this;
  }
  IntegerIterator operator--(int) {
    IntegerIterator copy = *this;
    --value;
    return copy;
  }
  T operator*() const { return value; }
  bool operator==(IntegerIterator rhs) const { return value == rhs.value; }
  bool operator!=(IntegerIterator rhs) const { return !(*this == rhs); }

 private:
  T value;
};
template <typename T>
class IntegerRange {
 public:
  IntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }
  IntegerIterator<T> begin() const { return IntegerIterator<T>(begin_); }
  IntegerIterator<T> end() const { return IntegerIterator<T>(end_); }

 private:
  T begin_;
  T end_;
};
template <typename T>
class ReversedIntegerRange {
 public:
  ReversedIntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }
  std::reverse_iterator<IntegerIterator<T>> begin() const {
    return std::reverse_iterator<IntegerIterator<T>>(
        IntegerIterator<T>(begin_));
  }
  std::reverse_iterator<IntegerIterator<T>> end() const {
    return std::reverse_iterator<IntegerIterator<T>>(IntegerIterator<T>(end_));
  }

 private:
  T begin_;
  T end_;
};
template <typename T>
IntegerRange<T> range(T to) {
  return IntegerRange<T>(0, to);
}
template <typename T>
IntegerRange<T> range(T from, T to) {
  return IntegerRange<T>(from, to);
}
template <typename T>
IntegerRange<T> inclusiveRange(T to) {
  return IntegerRange<T>(0, to + 1);
}
template <typename T>
IntegerRange<T> inclusiveRange(T from, T to) {
  return IntegerRange<T>(from, to + 1);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from) {
  return ReversedIntegerRange<T>(from, 0);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from, T to) {
  return ReversedIntegerRange<T>(from, to);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from) {
  return ReversedIntegerRange<T>(from + 1, 0);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
  return ReversedIntegerRange<T>(from + 1, to);
}
template <typename T>
T gcd(T a, T b) {
  while (b) {
    T tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}
template <typename T>
T extendedGcd(T a, T b, T& x, T& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T d = extendedGcd(b % a, a, y, x);
  x -= (b / a) * y;
  return d;
}
using namespace std;
class TaskC {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int64_t n, m, k;
    in >> n >> m >> k;
    int64_t N = 2 * n;
    int64_t M = 2 * m;
    int64_t g = gcd(N, M);
    int64_t LCM = N * M / g;
    auto solve = [&](int64_t x, int64_t y) -> int64_t {
      if ((y - x) % g) {
        return numeric_limits<int64_t>::max();
      }
      int64_t k, l;
      extendedGcd(N, M, k, l);
      k *= (y - x) / g;
      int64_t res = N * k + x;
      res %= LCM;
      if (res < 0) {
        res += LCM;
      }
      return res;
    };
    int64_t z, u;
    for (int64_t i : range(k)) {
      int64_t x, y;
      in >> x >> y;
      int64_t ans = numeric_limits<int64_t>::max();
      for (int64_t xx : {x, 2 * n - x}) {
        for (int64_t yy : {y, 2 * m - y}) {
          auto tt = solve(xx, yy);
          if (tt == numeric_limits<int64_t>::max()) continue;
          ans = min(ans, tt);
        }
      }
      if (ans == numeric_limits<int64_t>::max()) {
        out << -1;
      } else {
        out << ans;
      }
      out << "\n";
    }
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  TaskC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  in.tie(0);
  out << std::fixed;
  out.precision(20);
  return 0;
}
