#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > d1[200010];
vector<pair<int, int> > d2[200010];
int bd[100010][2];
const int el = 100005;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  map<pair<int, int>, long long> id;
  vector<pair<int, int> > anw;
  n++;
  m++;
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    d1[x - y + el].push_back(make_pair(x, y));
    d2[(n - x - 1) - y + el].push_back(make_pair(x, y));
    anw.push_back(make_pair(x, y));
  }
  for (int i = 0; i < 200007; i++) {
    sort(d1[i].begin(), d1[i].end());
    sort(d2[i].begin(), d2[i].end());
  }
  int dr = 0;
  int xp, yp;
  xp = 0;
  yp = 0;
  long long c = 0;
  set<pair<int, int> > vis;
  while (true) {
    if (vis.count(make_pair(xp, yp))) break;
    vis.insert(make_pair(xp, yp));
    if (dr == 0) {
      for (int i = 0; i < d1[xp - yp + el].size(); i++) {
        if (!id.count(d1[xp - yp + el][i]))
          id[d1[xp - yp + el][i]] = c + d1[xp - yp + el][i].first - xp;
      }
      int dx = (n - 1) - xp;
      int dy = (m - 1) - yp;
      if (dx == dy) break;
      if (dx < dy)
        dr = 1;
      else
        dr = 3;
      if (dx > dy) swap(dx, dy);
      c += dx;
      xp += dx;
      yp += dx;
    } else if (dr == 1) {
      int s = d2[(n - 1 - xp) - yp + el].size();
      for (int i = 0; i < s; i++) {
        if (!id.count(d2[(n - 1 - xp) - yp + el][s - i - 1]))
          id[d2[(n - 1 - xp) - yp + el][s - i - 1]] =
              c + xp - d2[(n - 1 - xp) - yp + el][s - i - 1].first;
      }
      int dx = xp;
      int dy = (m - 1) - yp;
      if (dx == dy) break;
      if (dx < dy)
        dr = 0;
      else
        dr = 2;
      if (dx > dy) swap(dx, dy);
      c += dx;
      xp -= dx;
      yp += dx;
    } else if (dr == 2) {
      int s = d1[xp - yp + el].size();
      for (int i = 0; i < s; i++) {
        if (!id.count(d1[xp - yp + el][s - i - 1]))
          id[d1[xp - yp + el][s - i - 1]] =
              c + xp - d1[xp - yp + el][s - i - 1].first;
      }
      int dx = xp;
      int dy = yp;
      if (dx == dy) break;
      if (dx < dy)
        dr = 3;
      else
        dr = 1;
      if (dx > dy) swap(dx, dy);
      c += dx;
      xp -= dx;
      yp -= dx;
    } else {
      int s = d2[(n - 1 - xp) - yp + el].size();
      for (int i = 0; i < s; i++) {
        if (!id.count(d2[(n - 1 - xp) - yp + el][i]))
          id[d2[(n - 1 - xp) - yp + el][i]] =
              c + d2[(n - 1 - xp) - yp + el][i].first - xp;
      }
      int dx = (n - 1) - xp;
      int dy = yp;
      if (dx == dy) break;
      if (dx < dy)
        dr = 2;
      else
        dr = 0;
      if (dx > dy) swap(dx, dy);
      c += dx;
      xp += dx;
      yp -= dx;
    }
  }
  for (int i = 0; i < anw.size(); i++) {
    if (id.count(anw[i]))
      printf("%I64d\n", id[anw[i]]);
    else
      printf("%d\n", -1);
  }
}
