#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 100005;
struct node {
  int x, y, id;
  node() {}
  node(int _x, int _y, int _id) : x(_x), y(_y), id(_id) {}
};
vector<node> f1[N * 2], f2[N * 2];
int n, m, K;
long long ans[N];
long long a[N * 2], b[N * 2];
pair<int, int> S1[N * 2], S2[N * 2];
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= K; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    f1[b - a + N].push_back(node(a, b, i));
    f2[a + b].push_back(node(a, b, i));
  }
  memset(a, -1, sizeof(a));
  memset(b, -1, sizeof(b));
  long long pre = 0;
  int sx = 0, sy = 0, dx = 1, dy = 1;
  while (1) {
    if (dx * dy == 1) {
      if (a[sy - sx + N] == -1) {
        a[sy - sx + N] = pre;
        S1[sy - sx + N] = make_pair(sx, sy);
      }
    } else {
      if (b[sx + sy] == -1) {
        b[sx + sy] = pre;
        S2[sx + sy] = make_pair(sx, sy);
      }
    }
    int txx = sx;
    int tyy = sy;
    if (dx == 1 && dy == 1) {
      if (n + sy - sx == m) break;
      if (n + sy - sx < m) {
        int tmp = n + sy - sx;
        sx = n;
        sy = tmp;
        dx = -1;
        dy = 1;
      } else {
        int tmp = m - (sy - sx);
        sx = tmp;
        sy = m;
        dx = 1;
        dy = -1;
      }
    } else if (dx == 1 && dy == -1) {
      if (-n + (sx + sy) == 0) break;
      if (-n + (sx + sy) > 0) {
        int tmp = -n + (sx + sy);
        sx = n;
        sy = tmp;
        dx = -1;
        dy = -1;
      } else {
        int tmp = -(0 - (sx + sy));
        sx = tmp;
        sy = 0;
        dx = 1;
        dy = 1;
      }
    } else if (dx == -1 && dy == 1) {
      if ((sx + sy) == m) break;
      if (sx + sy < m) {
        int tmp = sx + sy;
        sx = 0;
        sy = tmp;
        dx = 1;
        dy = 1;
      } else {
        int tmp = -(m - (sx + sy));
        sx = tmp;
        sy = m;
        dx = -1;
        dy = -1;
      }
    } else {
      if (0 + (sy - sx) == 0) break;
      if (sy - sx > 0) {
        int tmp = sy - sx;
        sx = 0;
        sy = tmp;
        dx = 1;
        dy = -1;
      } else {
        int tmp = 0 - (sy - sx);
        sx = tmp;
        sy = 0;
        dx = -1;
        dy = 1;
      }
    }
    pre += abs(sx - txx);
  }
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < N * 2; ++i)
    if (a[i] != -1) {
      for (int j = 0; j < int(f1[i].size()); ++j) {
        node p = f1[i][j];
        long long tmp = a[i] + abs(S1[i].first - p.x);
        if (ans[p.id] == -1 || ans[p.id] > tmp) ans[p.id] = tmp;
      }
    }
  for (int i = 0; i < N * 2; ++i)
    if (b[i] != -1) {
      for (int j = 0; j < int(f2[i].size()); ++j) {
        node p = f2[i][j];
        long long tmp = b[i] + abs(S2[i].first - p.x);
        if (ans[p.id] == -1 || ans[p.id] > tmp) ans[p.id] = tmp;
      }
    }
  for (int i = 1; i <= K; ++i) printf("%I64d\n", ans[i]);
}
