#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m, s;
const int maxn = 2e5 + 10;
int xx[] = {0, 1, 1, -1, -1};
int yy[] = {0, 1, -1, -1, 1};
map<pair<int, int>, pair<int, int> > start;
map<pair<int, int>, long long> cost;
int solve(int a, int b) {
  int curx = 0, cury = 0;
  int dir = 1;
  int ans = -1;
  long long ti = 0;
  bool strr = 0;
  start[make_pair(1, 0)] = make_pair(0, 0);
  cost[make_pair(1, 0)] = 0;
  while (1) {
    if ((curx == 0 && (cury == 0 || cury == m) ||
         curx == n && (cury == 0 || cury == m)) &&
        strr)
      return ans;
    strr = 1;
    int lasdir = dir;
    int tempx = curx, tempy = cury;
    int mov;
    if (dir == 1) {
      mov = min(n - curx, m - cury);
      curx += mov, cury += mov;
      if (curx == n)
        dir = 4;
      else
        dir = 2;
    } else if (dir == 2) {
      mov = min(n - curx, cury);
      curx += mov, cury -= mov;
      if (curx == n)
        dir = 3;
      else
        dir = 1;
    } else if (dir == 3) {
      mov = min(curx, cury);
      curx -= mov, cury -= mov;
      if (cury == 0)
        dir = 4;
      else
        dir = 2;
    } else if (dir == 4) {
      mov = min(curx, m - cury);
      curx -= mov, cury += mov;
      if (curx == 0)
        dir = 1;
      else
        dir = 3;
    }
    int xie = (lasdir == 1 || lasdir == 3) ? 1 : -1;
    pair<int, int> tem = make_pair(xie, tempy - tempx * xie);
    start[tem] = make_pair(tempx, tempy);
    cost[tem] = ti;
    ti += mov;
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int u, v, t;
  long long x, a, b, c, d, q;
  int curx = 0, cury = 0;
  cin >> n >> m >> q;
  solve(1, 1);
  while (q--) {
    cin >> a >> b;
    pair<int, int> tmp1 = make_pair(1, b - a);
    pair<int, int> tmp2 = make_pair(-1, b + a);
    long long as2 = -1;
    if (start.count(tmp1)) {
      pair<int, int> pp = start[tmp1];
      as2 = max(as2, cost[tmp1] + abs(a - pp.first));
    }
    if (start.count(tmp2)) {
      pair<int, int> pp = start[tmp2];
      long long tmp = cost[tmp2] + abs(a - pp.first);
      if (as2 != -1)
        as2 = min(as2, tmp);
      else
        as2 = tmp;
    }
    cout << as2 << endl;
  }
  return 0;
}
