#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int x[maxn], y[maxn];
vector<pair<int, int> > vec[2][maxn << 1];
map<pair<int, int>, long long> ans;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d%d", x + i, y + i);
    vec[0][x[i] + y[i]].push_back({x[i], y[i]});
    vec[1][x[i] - y[i] + maxn].push_back({x[i], y[i]});
  }
  int tag = 1;
  int X = 0, Y = 0;
  long long T = 0;
  for (int i = 0; i < vec[tag][maxn].size(); i++) {
    pair<int, int> m = {vec[tag][maxn][i].first, vec[tag][maxn][i].second};
    if (ans[m] == 0) ans[m] = abs(vec[tag][maxn][i].first - X);
  }
  T = min(m, n);
  X = Y = min(m, n);
  while (!(X == 0 && Y == m || X == n && Y == m || X == n && Y == 0)) {
    tag ^= 1;
    int ttt = tag ? X - Y + maxn : X + Y;
    for (int i = 0; i < vec[tag][ttt].size(); i++) {
      pair<int, int> m = {vec[tag][ttt][i].first, vec[tag][ttt][i].second};
      if (ans[m] == 0) ans[m] = abs(vec[tag][ttt][i].first - X) + T;
    }
    int tx = X, ty = Y;
    if (X == n) {
      if (tag == 0) {
        if (m - Y < n)
          X = n - (m - Y), Y = m;
        else
          Y += n, X = 0;
      } else {
        if (Y < n)
          X = n - Y, Y = 0;
        else
          Y -= n, X = 0;
      }
    } else if (X == 0) {
      if (tag == 0) {
        if (Y < n)
          X = Y, Y = 0;
        else
          Y -= n, X = n;
      } else {
        if (m - Y < n)
          X = m - Y, Y = m;
        else
          Y += n, X = n;
      }
    } else if (Y == m) {
      if (tag == 0) {
        if (n - X < m)
          Y = m - (n - X), X = n;
        else
          X = X + m, Y = 0;
      } else {
        if (X < m)
          Y = m - X, X = 0;
        else
          X -= m, Y = 0;
      }
    } else if (Y == 0) {
      if (tag == 0) {
        if (X < m)
          Y = X, X = 0;
        else
          X = X - m, Y = m;
      } else {
        if (n - X < m)
          Y = n - X, X = n;
        else
          X = X + m, Y = m;
      }
    }
    T += abs(X - tx);
  }
  for (int i = 0; i < k; i++) {
    pair<int, int> m = {x[i], y[i]};
    long long tmp = ans[m];
    if (tmp == 0)
      printf("%d\n", -1);
    else
      printf("%I64d\n", tmp);
  }
  return 0;
}
