#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct point {
  int x, y, ind;
};
vector<point> fd[200200];
vector<point> bd[200200];
long long out[100100];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  memset(out, -1, sizeof out);
  for (int i = 0, x, y; i < k; ++i) {
    scanf("%d%d", &x, &y);
    fd[x - y + m].push_back({x, y, i});
    bd[x + y].push_back({x, y, i});
  }
  int x = 0, y = 0, dx = 1, dy = 1;
  long long t = 0;
  while (true) {
    if (dx == dy) {
      int l = x - y + m;
      for (int i = 0; i < (int)fd[l].size(); ++i) {
        point &p = fd[l][i];
        if (out[p.ind] != -1) continue;
        long long dfx = x - p.x;
        out[p.ind] = t + abs(dfx);
      }
    } else {
      int l = x + y;
      for (int i = 0; i < (int)bd[l].size(); ++i) {
        point &p = bd[l][i];
        if (out[p.ind] != -1) continue;
        long long dfx = x - p.x;
        out[p.ind] = t + abs(dfx);
      }
    }
    int mh, mv;
    if (dx == 1)
      mh = n - x;
    else
      mh = x;
    if (dy == 1)
      mv = m - y;
    else
      mv = y;
    if (mh < mv) {
      if (dx == 1)
        x = n;
      else
        x = 0;
      t += mh;
      y += mh * dy;
      dx *= -1;
    } else if (mh > mv) {
      if (dy == 1)
        y = m;
      else
        y = 0;
      t += mv;
      x += mv * dx;
      dy *= -1;
    } else {
      break;
    }
  }
  for (int i = 0; i < k; ++i) printf("%I64d\n", out[i]);
  return 0;
}
