#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int MINUS = 0;
const int PLUS = 1;
const int UP = 0;
const int DOWN = 1;
int n, m, k;
struct Point {
  int x, y;
  Point(int x, int y) : x(x), y(y) {}
  bool operator<(const Point &o) const {
    if (x != o.x) return x < o.x;
    return y < o.y;
  }
};
map<int, vector<Point> > dm;
map<int, vector<Point> > dp;
long long ans[N];
void solve(int x, int y, int t, int dir, int &u, int &v, int &newT,
           int &newDir) {
  newT = t ^ 1;
  if (t == MINUS) {
    int a = x - y;
    if (dir == UP) {
      u = min(n, m + a);
      v = u - a;
      if (u == n)
        newDir = DOWN;
      else
        newDir = UP;
    } else {
      u = max(a, 0);
      v = u - a;
      if (u == 0)
        newDir = UP;
      else
        newDir = DOWN;
    }
  } else {
    int a = x + y;
    if (dir == UP) {
      u = min(n, a);
      v = a - u;
      if (u == n)
        newDir = DOWN;
      else
        newDir = UP;
    } else {
      u = max(a - m, 0);
      v = a - u;
      if (u == 0)
        newDir = UP;
      else
        newDir = DOWN;
    }
  }
}
bool isCorner(int x, int y) {
  if (x == 0 && y == 0) return true;
  if (x == 0 && y == m) return true;
  if (x == n && y == 0) return true;
  if (x == n && y == m) return true;
  return false;
}
void _main() {
  cin >> m >> n >> k;
  for (int i = 1; i <= k; ++i) {
    int x, y;
    cin >> y >> x;
    dm[x - y].push_back(Point(x, i));
    dp[x + y].push_back(Point(x, i));
  }
  memset(ans, -1, sizeof ans);
  int x = 0, y = 0, t = MINUS, dir = UP;
  long long Time = 0;
  set<Point> was;
  while (!was.count(Point(x, y))) {
    was.insert(Point(x, y));
    int u, v, newT, newDir;
    solve(x, y, t, dir, u, v, newT, newDir);
    if (t == MINUS) {
      auto &it = dm[x - y];
      sort(it.begin(), it.end());
      if (dir == DOWN) reverse(it.begin(), it.end());
      for (auto sen : it)
        if (ans[sen.y] == -1) ans[sen.y] = Time + abs(sen.x - x);
    } else {
      auto &it = dp[x + y];
      sort(it.begin(), it.end());
      if (dir == DOWN) reverse(it.begin(), it.end());
      for (auto sen : it)
        if (ans[sen.y] == -1) ans[sen.y] = Time + abs(sen.x - x);
    }
    Time += abs(u - x);
    x = u;
    y = v;
    t = newT;
    dir = newDir;
    if (isCorner(x, y)) break;
  }
  for (int i = 1; i <= k; ++i) cout << ans[i] << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  _main();
  cerr << setprecision(2) << fixed << endl
       << "__Elapsed__ " << (double)clock() / CLOCKS_PER_SEC << endl;
  return 0;
}
