#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y;
struct node {
  int y, id;
  bool operator<(const node &a) const { return y < a.y; }
};
map<pair<int, int>, long long> Map[4];
pair<int, int> res;
int ti[100005];
void Rd(int &x) {
  char c;
  x = 0;
  while (c = getchar(), !isdigit(c))
    ;
  do {
    x = (x << 3) + (x << 1) + (c ^ '0');
  } while (c = getchar(), isdigit(c));
}
long long mi(long long x, long long y) {
  if (x == -1) return y;
  return x < y ? x : y;
}
int main() {
  Rd(n), Rd(m), Rd(k);
  int nx = 0, ny = 0, D = 0;
  long long t = 0;
  res.first = nx, res.second = ny;
  Map[D][res] = t;
  while (1) {
    if (nx == 0 && ny == n) break;
    if (nx == m && ny == 0) break;
    if (nx == m && ny == n) break;
    if (D == 0) {
      int a = m - nx, b = n - ny;
      if (a > b) {
        nx += b, ny += b, t += b;
        D = 3;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      } else {
        nx += a, ny += a, t += a;
        D = 1;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      }
    } else if (D == 1) {
      int a = nx, b = n - ny;
      if (a > b) {
        nx -= b, ny += b, t += b;
        D = 2;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      } else {
        nx -= a, ny += a, t += a;
        D = 0;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      }
    } else if (D == 2) {
      int a = nx, b = ny;
      if (a > b) {
        nx -= b, ny -= b, t += b;
        D = 1;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      } else {
        nx -= a, ny -= a, t += a;
        D = 3;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      }
    } else {
      int a = m - nx, b = ny;
      if (a > b) {
        nx += b, ny -= b, t += b;
        D = 0;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      } else {
        nx += a, ny -= a, t += a;
        D = 2;
        res.first = nx, res.second = ny;
        Map[D][res] = t;
      }
    }
  }
  for (int i = 1; i <= k; i++) {
    Rd(x), Rd(y);
    swap(x, y);
    int a, b;
    long long ans = -1;
    a = x, b = y;
    if (a > b) {
      int s = b;
      a -= y, b -= y;
      D = 0;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    } else {
      int s = a;
      a -= x, b -= x;
      D = 0;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    }
    a = m - x, b = y;
    if (a > b) {
      int s = b;
      a = x + b, b = 0;
      D = 1;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    } else {
      int s = a;
      b = y - a, a = m;
      D = 1;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    }
    a = m - x, b = n - y;
    if (a > b) {
      int s = b;
      a = x + b, b = n;
      D = 2;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    } else {
      int s = a;
      b = y + a, a = m;
      D = 2;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    }
    a = x, b = n - y;
    if (a > b) {
      int s = b;
      a = x - b, b = n;
      D = 3;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    } else {
      int s = a;
      b = y + a, a = 0;
      D = 3;
      res.first = a, res.second = b;
      if (Map[D].find(res) != Map[D].end()) ans = mi(ans, Map[D][res] + s);
    }
    cout << ans << endl;
  }
  return 0;
}
