#include <bits/stdc++.h>
using namespace std;
struct det {
  int x;
  int y;
  int z;
  det() {}
  det(int x1, int y1, int z1) : x(x1), y(y1), z(z1) {}
};
bool comp(det& l, det& r) { return (l.x < r.x) || (l.x == r.x && l.y < r.y); }
int rind(det& a, int& m, int& n) { return n - 1 + a.y - a.x; }
int lind(det& a, int& m, int& n) { return -1 + a.x + a.y; }
int rind(int x, int y, int& m, int& n) { return n - 1 + y - x; }
int lind(int x, int y, int& m, int& n) { return x + y - 1; }
void utime(long long& time, long long newv) {
  if (time == -1ll) time = newv;
}
int main() {
  ios_base::sync_with_stdio(false);
  string day1, day2;
  int n, m, k;
  cin >> n >> m >> k;
  int x, y;
  vector<det> points(k);
  for (int i = 0; i < k; ++i) {
    cin >> x >> y;
    points[i] = det(x, y, i);
  }
  sort(points.begin(), points.end(), comp);
  vector<vector<det>> lefts(n + m - 1);
  vector<vector<det>> rights(n + m - 1);
  for (int i = 0; i < m; ++i) {
    rights[rind(0, i, m, n)].push_back(det(0, i, -1));
    lefts[lind(n, i, m, n)].push_back(det(n, i, -1));
  }
  for (int i = 1; i < n; ++i) {
    rights[rind(i, 0, m, n)].push_back(det(i, 0, -1));
    lefts[lind(i, 0, m, n)].push_back(det(i, 0, -1));
  }
  for (int i = 0; i < k; ++i) {
    det& cur = points[i];
    rights[rind(cur, m, n)].push_back(cur);
  }
  for (int i = k - 1; i >= 0; --i) {
    det& cur = points[i];
    lefts[lind(cur, m, n)].push_back(cur);
  }
  for (int i = 0; i < m; ++i) {
    rights[rind(n, i + 1, m, n)].push_back(det(n, i + 1, -1));
    lefts[lind(0, i + 1, m, n)].push_back(det(0, i + 1, -1));
  }
  for (int i = 0; i < n; ++i) {
    rights[rind(i + 1, m, m, n)].push_back(det(i + 1, m, -1));
    lefts[lind(i, m, m, n)].push_back(det(i, m, -1));
  }
  bool alive = true;
  int dx, dy;
  dx = 1;
  dy = 1;
  long long time = 0;
  vector<long long> times(k, -1ll);
  vector<int> ltouched(n + m - 1, 0);
  vector<int> rtouched(n + m - 1, 0);
  x = 0;
  y = 0;
  while (alive) {
    if (dx > 0 && dy > 0) {
      int tsize = rights[rind(x, y, m, n)].size();
      vector<det>& curline = rights[rind(x, y, m, n)];
      rtouched[rind(x, y, m, n)]++;
      if (rtouched[rind(x, y, m, n)] > 2) alive = false;
      for (int i = 0; i < tsize; ++i) {
        time = time + abs(curline[i].x - x);
        if (curline[i].z > -1) utime(times[curline[i].z], time);
        x = curline[i].x;
        y = curline[i].y;
      }
    }
    if (dx < 0 && dy < 0) {
      int tsize = rights[rind(x, y, m, n)].size();
      vector<det>& curline = rights[rind(x, y, m, n)];
      rtouched[rind(x, y, m, n)]++;
      if (rtouched[rind(x, y, m, n)] > 2) alive = false;
      for (int i = tsize - 1; i >= 0; --i) {
        time = time + abs(curline[i].x - x);
        if (curline[i].z > -1) utime(times[curline[i].z], time);
        x = curline[i].x;
        y = curline[i].y;
      }
    }
    if (dx > 0 && dy < 0) {
      int tsize = lefts[lind(x, y, m, n)].size();
      vector<det>& curline = lefts[lind(x, y, m, n)];
      ltouched[lind(x, y, m, n)]++;
      if (ltouched[lind(x, y, m, n)] > 2) alive = false;
      for (int i = tsize - 1; i >= 0; --i) {
        time = time + abs(curline[i].x - x);
        if (curline[i].z > -1) utime(times[curline[i].z], time);
        x = curline[i].x;
        y = curline[i].y;
      }
    }
    if (dx < 0 && dy > 0) {
      int tsize = lefts[lind(x, y, m, n)].size();
      vector<det>& curline = lefts[lind(x, y, m, n)];
      ltouched[lind(x, y, m, n)]++;
      if (ltouched[lind(x, y, m, n)] > 2) alive = false;
      for (int i = 0; i < tsize; ++i) {
        time = time + abs(curline[i].x - x);
        if (curline[i].z > -1) utime(times[curline[i].z], time);
        x = curline[i].x;
        y = curline[i].y;
      }
    }
    if ((x == n && y == m) || (x == 0 && y == 0) || (x == n && y == 0) ||
        (x == 0 && y == m)) {
      alive = false;
    }
    if (x == n) {
      dx *= -1;
    }
    if (y == m) {
      dy *= -1;
    }
    if (x == 0) {
      dx *= -1;
    }
    if (y == 0) {
      dy *= -1;
    }
  }
  for (int i = 0; i < k; ++i) cout << times[i] << "\n";
}
