#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 90000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
const int MX = 601000, c = 201000;
long long dp[MX][2][2];
int n, m;
bool invalid(int x, int y) { return x < 0 || y < 0 || x > n || y > m; }
bool isCorner(int x, int y) {
  return (x == 0 && y == 0) || (x == 0 && y == m) || (x == n && y == 0) ||
         (x == n && y == m);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int k;
  cin >> n >> m >> k;
  memset(dp, -1, sizeof(dp));
  int cur_x = 0, cur_y = 0, cur_diag = 0, cur_mode = 0;
  long long cur_time = 0;
  dp[c][cur_mode][cur_diag] = cur_time;
  do {
    ;
    if (!cur_diag && !cur_mode) {
      int diag_num = cur_y - cur_x;
      int px, py, qx, qy;
      px = n, py = n + cur_y - cur_x;
      qx = m + cur_x - cur_y, qy = m;
      ;
      if (invalid(px, py)) {
        cur_time += abs(cur_x - qx), cur_x = qx, cur_y = qy;
        cur_diag = 1;
        cur_mode = 0;
        diag_num = cur_y + cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      } else {
        cur_time += abs(cur_y - py), cur_x = px, cur_y = py;
        cur_diag = 1, cur_mode = 1;
        diag_num = cur_y + cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      }
    } else if (!cur_diag && cur_mode) {
      int diag_num = cur_y - cur_x;
      int px, py, qx, qy;
      px = 0, py = 0 + cur_y - cur_x;
      qy = 0, qx = 0 + cur_x - cur_y;
      if (invalid(px, py)) {
        cur_time += abs(cur_x - qx), cur_x = qx, cur_y = qy;
        cur_diag = 1, cur_mode = 1;
        diag_num = cur_y + cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      } else {
        cur_time += abs(cur_y - py), cur_x = px, cur_y = py;
        cur_diag = 1, cur_mode = 0;
        diag_num = cur_y + cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      }
    } else if (cur_diag && !cur_mode) {
      int diag_num = cur_y + cur_x;
      int px, py, qx, qy;
      px = diag_num, py = 0;
      qx = n, qy = diag_num - n;
      if (invalid(px, py)) {
        cur_time += abs(cur_x - qx), cur_x = qx, cur_y = qy;
        cur_diag = 0, cur_mode = 1;
        diag_num = cur_y - cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      } else {
        cur_time += abs(cur_y - py), cur_x = px, cur_y = py;
        cur_diag = 0, cur_mode = 0;
        diag_num = cur_y - cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      }
    } else if (cur_diag && cur_mode) {
      int diag_num = cur_y + cur_x;
      int px, py, qx, qy;
      px = 0, py = diag_num;
      qy = m;
      qx = diag_num - m;
      if (invalid(px, py)) {
        cur_time += abs(cur_x - qx), cur_x = qx, cur_y = qy;
        cur_diag = 0, cur_mode = 1;
        diag_num = cur_y - cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      } else {
        cur_time += abs(cur_y - py), cur_x = px, cur_y = py;
        cur_diag = 0, cur_mode = 0;
        diag_num = cur_y - cur_x;
        if (dp[diag_num + c][cur_diag][cur_mode] != -1) break;
        dp[diag_num + c][cur_diag][cur_mode] = cur_time;
      }
    }
  } while (!isCorner(cur_x, cur_y));
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    int diag1 = y - x, diag2 = x + y;
    long long ans = infLL;
    if (dp[diag1 + c][0][0] != -1LL) {
      int px, py, qx, qy;
      px = 0, py = 0 + y - x;
      qy = 0, qx = 0 + x - y;
      if (invalid(px, py))
        ans = min(ans, dp[diag1 + c][0][0] + abs(qx - x));
      else
        ans = min(ans, dp[diag1 + c][0][0] + abs(px - x));
    }
    if (dp[diag1 + c][0][1] != -1LL) {
      int px, py, qx, qy;
      px = n, py = n + y - x;
      qx = m + x - y, qy = m;
      if (invalid(px, py))
        ans = min(ans, dp[diag1 + c][0][1] + abs(qx - x));
      else
        ans = min(ans, dp[diag1 + c][0][1] + abs(px - x));
    }
    if (dp[diag2 + c][1][0] != -1LL) {
      int px, py, qx, qy;
      px = 0, py = diag2;
      qy = m;
      qx = diag2 - m;
      if (invalid(px, py))
        ans = min(ans, dp[diag2 + c][1][0] + abs(qx - x));
      else
        ans = min(ans, dp[diag2 + c][1][0] + abs(px - x));
    }
    if (dp[diag2 + c][1][1] != -1LL) {
      int px, py, qx, qy;
      px = diag2, py = 0;
      qx = n, qy = diag2 - n;
      if (invalid(px, py))
        ans = min(ans, dp[diag2 + c][1][1] + abs(qx - x));
      else
        ans = min(ans, dp[diag2 + c][1][1] + abs(px - x));
    }
    if (ans == infLL)
      cout << -1 << '\n';
    else
      cout << ans << '\n';
  }
  return 0;
}
