#include <bits/stdc++.h>
using namespace std;
const int N = 100007, mod = 1000000007, inf = 1000000007;
const long long lmod = 1000000007, linf = 1e18 + 77;
const long double eps = 1e-9;
pair<int, int> l[N];
map<pair<int, int>, int> M;
map<pair<int, int>, long long> T;
long long ans[N];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  scanf("%d", &k);
  ;
  for (int i = 0; i < k; i++) {
    ans[i] = linf;
    int x, y;
    scanf("%d", &x);
    ;
    scanf("%d", &y);
    ;
    l[i] = make_pair(x, y);
  }
  int x = 0;
  int y = 0;
  int d = 0;
  long long tim = 0;
  while (!((x == n && y == m) || (x == 0 && y == m) || (x == n && y == 0))) {
    if (d == 0) {
      if (n - x < m - y) {
        int len = n - x;
        tim += len;
        M[make_pair(x, y)] = d;
        x += len;
        y += len;
        T[make_pair(x, y)] = tim;
        d = 1;
      } else {
        int len = m - y;
        tim += len;
        M[make_pair(x, y)] = d;
        x += len;
        y += len;
        T[make_pair(x, y)] = tim;
        d = 3;
      }
      continue;
    }
    if (d == 1) {
      if (x < m - y) {
        int len = x;
        tim += len;
        M[make_pair(x, y)] = d;
        x -= len;
        y += len;
        T[make_pair(x, y)] = tim;
        d = 0;
      } else {
        int len = m - y;
        tim += len;
        M[make_pair(x, y)] = d;
        x -= len;
        y += len;
        T[make_pair(x, y)] = tim;
        d = 2;
      }
      continue;
    }
    if (d == 2) {
      if (x < y) {
        int len = x;
        tim += len;
        M[make_pair(x, y)] = d;
        x -= len;
        y -= len;
        T[make_pair(x, y)] = tim;
        d = 3;
      } else {
        int len = y;
        tim += len;
        M[make_pair(x, y)] = d;
        x -= len;
        y -= len;
        T[make_pair(x, y)] = tim;
        d = 1;
      }
      continue;
    }
    if (d == 3) {
      if (n - x < y) {
        int len = n - x;
        tim += len;
        M[make_pair(x, y)] = d;
        x += len;
        y -= len;
        T[make_pair(x, y)] = tim;
        d = 2;
      } else {
        int len = y;
        tim += len;
        M[make_pair(x, y)] = d;
        x += len;
        y -= len;
        T[make_pair(x, y)] = tim;
        d = 0;
      }
      continue;
    }
  }
  for (int i = 0; i < k; i++) {
    int x = l[i].first;
    int y = l[i].second;
    for (int d = 0; d < 4; d++) {
      int nx, ny, len;
      if (d == 0) {
        if (x < y) {
          len = x;
          nx = x - len;
          ny = y - len;
        } else {
          len = y;
          nx = x - len;
          ny = y - len;
        }
      }
      if (d == 1) {
        if (n - x < y) {
          len = n - x;
          nx = x + len;
          ny = y - len;
        } else {
          len = y;
          nx = x + len;
          ny = y - len;
        }
      }
      if (d == 2) {
        if (n - x < m - y) {
          len = n - x;
          nx = x + len;
          ny = y + len;
        } else {
          len = m - y;
          nx = x + len;
          ny = y + len;
        }
      }
      if (d == 3) {
        if (x < m - y) {
          len = x;
          nx = x - len;
          ny = y + len;
        } else {
          len = m - y;
          nx = x - len;
          ny = y + len;
        }
      }
      if (M.find(make_pair(nx, ny)) != M.end() && M[make_pair(nx, ny)] == d) {
        ans[i] = min(ans[i], T[make_pair(nx, ny)] + len);
      }
    }
  }
  for (int i = 0; i < k; i++) {
    if (ans[i] == linf) ans[i] = -1;
    printf("%I64d\n", ans[i]);
  }
}
