#include <bits/stdc++.h>
using namespace std;
const int mod = 100000007;
const int M = 100005;
const double pi = acos(-1);
struct pt {
  long long x, y, EWGDFGdfgfsdhfdshfdhf;
  bool operator<(const pt &a) const { return (x < a.x); }
  bool operator>(const pt &a) const { return (x > a.x); }
};
long long CAlASFSAF[100050], n, m, k;
set<pt> u[200050];
set<pt> d[200050];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  cin >> m;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    pt p;
    cin >> p.x;
    cin >> p.y;
    p.EWGDFGdfgfsdhfdshfdhf = i;
    u[p.y - p.x + 100000].insert(p);
    d[p.y + p.x].insert(p);
  }
  pt now, lst;
  now.x = 0;
  now.y = 0;
  now.EWGDFGdfgfsdhfdshfdhf = 0;
  long long xPXPXPPXXPXP = 1, nowdy = 1;
  for (int i = 1; i <= k; i++) CAlASFSAF[i] = -1;
  CAlASFSAF[0] = 0;
  long long NTNTNFN = 0, PLOPLO = 0;
  set<pt>::iterator ite;
  while (true) {
    lst = now;
    if (nowdy == 1) {
      if (xPXPXPPXXPXP == 1) {
        while (!u[now.y - now.x + 100000].empty()) {
          lst = now;
          NTNTNFN = PLOPLO;
          now = *(u[now.y - now.x + 100000].begin());
          PLOPLO = NTNTNFN + abs(now.x - lst.x);
          if (CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] == -1)
            CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] = PLOPLO;
          u[now.y - now.x + 100000].erase(u[now.y - now.x + 100000].begin());
        }
      } else {
        while (!d[now.y + now.x].empty()) {
          lst = now;
          NTNTNFN = PLOPLO;
          ite = d[now.y + now.x].end();
          ite--;
          now = *ite;
          PLOPLO = NTNTNFN + abs(now.x - lst.x);
          if (CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] == -1)
            CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] = PLOPLO;
          d[now.y + now.x].erase(ite);
        }
      }
    } else {
      if (xPXPXPPXXPXP == 1) {
        while (!d[now.y + now.x].empty()) {
          lst = now;
          NTNTNFN = PLOPLO;
          now = *(d[now.y + now.x].begin());
          PLOPLO = NTNTNFN + abs(now.x - lst.x);
          if (CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] == -1)
            CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] = PLOPLO;
          d[now.y + now.x].erase(d[now.y + now.x].begin());
        }
      } else {
        while (!u[now.y - now.x + 100000].empty()) {
          lst = now;
          NTNTNFN = PLOPLO;
          ite = u[now.y - now.x + 100000].end();
          ite--;
          now = *ite;
          PLOPLO = NTNTNFN + abs(now.x - lst.x);
          if (CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] == -1)
            CAlASFSAF[now.EWGDFGdfgfsdhfdshfdhf] = PLOPLO;
          u[now.y - now.x + 100000].erase(ite);
        }
      }
    }
    pt tr = now;
    tr.x += (xPXPXPPXXPXP * min(abs(now.x - (xPXPXPPXXPXP == 1 ? n : 0)),
                                abs(now.y - (nowdy == 1 ? m : 0))));
    tr.y += (nowdy * min(abs(now.x - (xPXPXPPXXPXP == 1 ? n : 0)),
                         abs(now.y - (nowdy == 1 ? m : 0))));
    tr.EWGDFGdfgfsdhfdshfdhf = 0;
    PLOPLO = PLOPLO + abs(tr.x - now.x);
    if (((tr.x == 0) || (tr.x == n)) && ((tr.y == 0) || (tr.y == m))) break;
    if (((xPXPXPPXXPXP == 1) && (tr.x == n)) ||
        ((xPXPXPPXXPXP == -1) && (tr.x == 0)))
      xPXPXPPXXPXP *= (-1);
    if (((nowdy == 1) && (tr.y == m)) || ((nowdy == -1) && (tr.y == 0)))
      nowdy *= (-1);
    now = tr;
  }
  for (int i = 1; i <= k; i++) {
    cout << CAlASFSAF[i] << endl;
  }
  return 0;
}
