#include <bits/stdc++.h>
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10;
const long long mod7 = 1e9 + 7;
const long long mod9 = 1e9 + 9;
using namespace std;
inline long long rit() {
  long long f = 0, key = 1;
  char c;
  do {
    c = getchar();
    if (c == '-') key = -1;
  } while (c < '0' || c > '9');
  do {
    f = f * 10 + c - '0';
    c = getchar();
  } while (c >= '0' && c <= '9');
  return f * key;
}
inline void fprt(double f) { printf("%.08lf", f); }
pair<int, int> dir[4];
void init() {
  dir[0] = make_pair(1, 1);
  dir[1] = make_pair(-1, 1);
  dir[2] = make_pair(-1, -1);
  dir[3] = make_pair(1, -1);
}
const int Z = 100005;
int n, m, k, tt, nxtdir;
inline pair<int, int> walk(int x, int y, int key) {
  int xd, yd, ans;
  xd = dir[key].first;
  yd = dir[key].second;
  ans = INF;
  if (xd == -1)
    ans = min(ans, x);
  else
    ans = min(ans, n - x);
  if (yd == -1)
    ans = min(ans, y);
  else
    ans = min(ans, m - y);
  tt = ans;
  return make_pair(x + ans * xd, y + ans * yd);
}
pair<int, int> s[Z];
map<pair<int, int>, long long> wall;
void read() {
  n = rit(), m = rit(), k = rit();
  ;
  for (int i = 0; i < k; i++) {
    s[i].first = rit(), s[i].second = rit();
    ;
  }
}
void solve() {
  int x, y, key;
  long long d, cnt;
  pair<int, int> f;
  wall[make_pair(0, 0)] = 0;
  cnt = 0;
  x = y = 0;
  while (1) {
    key = 0;
    for (int i = 0; i < 4; i++) {
      f = walk(x, y, i);
      if (wall.find(make_pair(f.first, f.second)) == wall.end()) {
        x = f.first;
        y = f.second;
        cnt += tt;
        wall[make_pair(x, y)] = cnt;
        key = 1;
        break;
      }
    }
    if (!key) break;
  }
  for (int i = 0; i < k; i++) {
    x = s[i].first;
    y = s[i].second;
    d = -1;
    for (int j = 0; j < 4; j++) {
      f = walk(x, y, j);
      if (wall.find(f) != wall.end()) {
        if (d == -1)
          d = wall[f] + abs(x - f.first);
        else
          d = min(d, wall[f] + abs(x - f.first));
      }
    }
    cout << d << endl;
  }
}
int main() {
  int nn = 1;
  init();
  while (nn--) {
    read();
    solve();
  }
  return 0;
}
