#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int oo = 1000000007;
int n, m, k;
pair<int, int> sen[N];
vector<pair<int, int> > h0[2][N], hm[2][N], v0[2][N], vn[2][N];
bool corner(int x, int y) {
  if (x == 0 && y == 0) return true;
  if (x == n && y == m) return true;
  if (x == n && y == 0) return true;
  return x == 0 && y == m;
}
void cast1(pair<int, int> coor, pair<int, int> &low, pair<int, int> &up,
           int &dlow, int &dup) {
  int x = coor.first, y = coor.second;
  low = make_pair(0, 0), up = make_pair(0, 0);
  int temp = min(n - x, m - y);
  up = make_pair(x + temp, y + temp);
  dup = temp;
  temp = min(x, y);
  low = make_pair(x - temp, y - temp);
  dlow = temp;
}
void cast0(pair<int, int> coor, pair<int, int> &low, pair<int, int> &up,
           int &dlow, int &dup) {
  int x = coor.first, y = coor.second;
  low = make_pair(0, 0), up = make_pair(0, 0);
  int temp = min(x, m - y);
  up = make_pair(x - temp, y + temp);
  dup = temp;
  temp = min(n - x, y);
  low = make_pair(x + temp, y - temp);
  dlow = temp;
}
long long ans[N];
map<pair<int, int>, bool> mark;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= (k); ++i) scanf("%d%d", &sen[i].first, &sen[i].second);
  pair<int, int> low, up;
  int d1, d2;
  for (int i = 1; i <= (k); ++i) {
    cast1(sen[i], low, up, d1, d2);
    if (low.first == 0) v0[1][low.second].push_back(make_pair(i, d1));
    if (low.second == 0) h0[1][low.first].push_back(make_pair(i, d1));
    if (up.first == n) vn[1][up.second].push_back(make_pair(i, d2));
    if (up.second == m) hm[1][up.first].push_back(make_pair(i, d2));
    cast0(sen[i], low, up, d1, d2);
    if (low.first == n) vn[0][low.second].push_back(make_pair(i, d1));
    if (low.second == 0) h0[0][low.first].push_back(make_pair(i, d1));
    if (up.first == 0) v0[0][up.second].push_back(make_pair(i, d2));
    if (up.second == m) hm[0][up.first].push_back(make_pair(i, d2));
  }
  for (int i = 1; i <= (k); ++i) ans[i] = -1;
  int x = 0, y = 0, c = 1;
  long long t = 0;
  do {
    if (x == 0) {
      for (__typeof(v0[c][y].begin()) it = v0[c][y].begin();
           it != v0[c][y].end(); ++it) {
        int ind = it->first, w = it->second;
        if (ans[ind] == -1) ans[ind] = t + w;
      }
    } else {
      if (y == 0) {
        for (__typeof(h0[c][x].begin()) it = h0[c][x].begin();
             it != h0[c][x].end(); ++it) {
          int ind = it->first, w = it->second;
          if (ans[ind] == -1) ans[ind] = t + w;
        }
      } else {
        if (x == n) {
          for (__typeof(vn[c][y].begin()) it = vn[c][y].begin();
               it != vn[c][y].end(); ++it) {
            int ind = it->first, w = it->second;
            if (ans[ind] == -1) ans[ind] = t + w;
          }
        } else {
          for (__typeof(hm[c][x].begin()) it = hm[c][x].begin();
               it != hm[c][x].end(); ++it) {
            int ind = it->first, w = it->second;
            if (ans[ind] == -1) ans[ind] = t + w;
          }
        }
      }
    }
    if (c == 1)
      cast1(make_pair(x, y), low, up, d1, d2);
    else
      cast0(make_pair(x, y), low, up, d1, d2);
    if (low == make_pair(x, y)) {
      t += d2;
      x = up.first;
      y = up.second;
    } else {
      t += d1;
      x = low.first;
      y = low.second;
    }
    if (mark[make_pair(x, y)])
      break;
    else
      mark[make_pair(x, y)] = true;
    c = !c;
  } while (!corner(x, y));
  for (int i = 1; i <= (k); ++i) printf("%I64d\n", ans[i]);
}
