#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18;
const double eps = 1e-7;
const int MAX_MEM = 1e8;
int mpos = 0;
char mem[MAX_MEM];
inline void *operator new(size_t n) {
  char *res = mem + mpos;
  mpos += n;
  assert(mpos <= MAX_MEM);
  return (void *)res;
}
inline void operator delete(void *) {}
inline void *operator new[](size_t) { assert(0); }
inline void operator delete[](void *) { assert(0); }
int used[2][200500];
long long t[100500];
vector<pair<int, int> > sp[2][200500];
int n, m;
pair<int, int> get_first(int num, int type) {
  pair<int, int> ans;
  if (type) {
    if (num > n)
      ans.first = 0, ans.second = num - n;
    else
      ans.first = n - num, ans.second = 0;
  } else {
    if (num <= n) {
      ans.first = num, ans.second = 0;
    } else
      ans.first = n, ans.second = num - n;
  }
  return ans;
}
int get_num(int x, int y, int type) {
  if (type) {
    return n - x + y;
  }
  return x + y;
}
pair<int, int> get_last(int num, int type) {
  pair<int, int> ans;
  if (type) {
    if (num <= m) {
      ans.first = n, ans.second = num;
    } else
      ans.first = n - (num - m), ans.second = m;
  } else {
    if (num <= m)
      ans.first = 0, ans.second = num;
    else
      ans.first = num - m, ans.second = m;
  }
  return ans;
}
long long ans[100500];
bool check_last(pair<int, int> a) {
  return (a.first == 0 || a.first == n) && (a.second == 0 || a.second == m);
}
void em() {
  int type = 1;
  int num = n;
  int nap = 0;
  long long cur_t = 0;
  while (1) {
    if (used[type][num]) return;
    used[type][num] = 1;
    vector<pair<int, int> > &cur = sp[type][num];
    pair<int, int> a = get_first(num, type);
    pair<int, int> b = get_last(num, type);
    if (nap) {
      for (int i = (int)cur.size() - 1; i >= 0; --i) {
        long long x = cur[i].first, j = cur[i].second;
        ans[j] = min(ans[j], cur_t + abs(x - b.first));
      }
    } else {
      for (int i = 0; i < (int)cur.size(); ++i) {
        long long x = cur[i].first, j = cur[i].second;
        ans[j] = min(ans[j], cur_t + abs(x - a.first));
      }
    }
    cur_t += abs(a.first - b.first);
    if (nap) {
      swap(a, b);
    }
    if (check_last(b)) return;
    type ^= 1;
    num = get_num(b.first, b.second, type);
    if (b == get_first(num, type))
      nap = 0;
    else
      nap = 1;
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    pair<int, int> a;
    cin >> a.first >> a.second;
    ans[i] = infl;
    sp[0][a.first + a.second].push_back(make_pair(a.first, i));
    sp[1][get_num(a.first, a.second, 1)].push_back(make_pair(a.first, i));
  }
  for (int i = 0; i <= n + m; ++i) {
    sort(sp[0][i].begin(), sp[0][i].end());
    sort(sp[1][i].begin(), sp[1][i].end());
  }
  em();
  for (int i = 0; i < k; ++i) {
    if (ans[i] < infl) {
      cout << ans[i] << '\n';
    } else
      cout << "-1\n";
  }
  return 0;
}
