#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(const T &a) {
  return a * a;
}
template <class T>
inline int len(const T &c) {
  return static_cast<int>(c.size());
}
template <class T>
inline bool maximize(T &r, const T c) {
  if (r < c) {
    r = c;
    return true;
  }
  return false;
}
template <class T>
inline bool minimize(T &r, const T c) {
  if (r > c) {
    r = c;
    return true;
  }
  return false;
}
const long double EPS = 1e-9;
const long double PI = 2 * acos(0.0);
const int N = 100;
void Add(map<pair<pair<int, int>, pair<int, int>>, vector<int>> &m,
         pair<pair<int, int>, pair<int, int>> from, int to) {
  if (m.count(from)) {
    m[from].push_back(to);
  } else {
    m[from] = {to};
  }
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  map<pair<pair<int, int>, pair<int, int>>, vector<int>> dia;
  vector<pair<int, int>> sensors;
  for (int i = 0; i < k; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    sensors.push_back({x, y});
    int lf = max(0, x - y);
    int rg = min(n, n - ((n - x) - (m - y)));
    int ly = y - (x - lf);
    int ry = y + (rg - x);
    Add(dia, {{lf, ly}, {rg, ry}}, i);
    lf = max(0, x - (m - y));
    rg = min(n, n - ((n - x) - y));
    ly = y + (x - lf);
    ry = y - (rg - x);
    Add(dia, {{lf, ly}, {rg, ry}}, i);
  }
  set<pair<int, int>> used;
  pair<int, int> cur{0, 0};
  pair<int, int> dir{1, 1};
  vector<long long> ans(k, -1);
  int found = 0;
  long long timer = 0;
  while (!used.count(cur) && found < k) {
    used.insert(cur);
    int dt = 1e9;
    if (dir.first < 0) {
      minimize(dt, cur.first);
    } else {
      minimize(dt, n - cur.first);
    }
    if (dir.second < 0) {
      minimize(dt, cur.second);
    } else {
      minimize(dt, m - cur.second);
    }
    pair<int, int> next{cur.first + dir.first * dt,
                        cur.second + dir.second * dt};
    pair<int, int> lf = min(cur, next);
    pair<int, int> rg = max(cur, next);
    for (int sid : dia[{lf, rg}]) {
      if (ans[sid] == -1) {
        int dx = cur.first - sensors[sid].first;
        int dy = cur.second - sensors[sid].second;
        ans[sid] = timer + min(abs(dx), abs(dy));
        ++found;
      }
    }
    bool y_refl = next.second == m || next.second == 0;
    bool x_refl = next.first == 0 || next.first == n;
    if (x_refl && y_refl) {
      break;
    }
    if (x_refl) dir.first *= -1;
    if (y_refl) dir.second *= -1;
    timer += abs(next.first - cur.first);
    cur = next;
  }
  for (long long x : ans) {
    printf("%lld\n", x);
  }
  return 0;
}
