#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n, m, k;
set<pair<int, int> > s1[MAXN], s2[MAXN];
set<pair<int, int> >::iterator it;
long long ans[MAXN];
int r[MAXN][2], c[MAXN][2];
void solve() {
  memset(r, 0, sizeof r);
  memset(c, 0, sizeof c);
  for (int i = 0; i <= n + m; ++i) {
    s1[i].clear();
    s2[i].clear();
  }
  for (int i = 1; i <= k; ++i) {
    int x, y;
    ans[i] = -1;
    scanf("%d%d", &x, &y);
    s1[x + y].insert(pair<int, int>(y, i));
    s2[x - y + m].insert(pair<int, int>(y, i));
  }
  int dx = 1, dy = 1;
  int x = 0, y = 0;
  long long t = 0;
  for (int i = 1; i <= 5 * (n + m); ++i) {
    if (dx == 1) {
      if (dy == 1) {
        for (it = s2[x - y + m].begin(); it != s2[x - y + m].end(); ++it) {
          if (ans[it->second] == -1) ans[it->second] = t + it->first - y;
        }
        s2[x - y + m].clear();
        int d = min(n - x, m - y);
        x += d;
        y += d;
        t += d;
        if (x == n) dx = 1 - dx;
        if (y == m) dy = 1 - dy;
      } else {
        for (it = s1[x + y].begin(); it != s1[x + y].end(); ++it) {
          if (ans[it->second] == -1) ans[it->second] = t + y - it->first;
        }
        s1[x + y].clear();
        int d = min(n - x, y);
        x += d;
        y -= d;
        t += d;
        if (x == n) dx = 1 - dx;
        if (y == 0) dy = 1 - dy;
      }
    } else {
      if (dy == 1) {
        for (it = s1[x + y].begin(); it != s1[x + y].end(); ++it) {
          if (ans[it->second] == -1) ans[it->second] = t + it->first - y;
        }
        s1[x + y].clear();
        int d = min(x, m - y);
        x -= d;
        y += d;
        t += d;
        if (x == 0) dx = 1 - dx;
        if (y == m) dy = 1 - dy;
      } else {
        for (it = s2[x - y + m].begin(); it != s2[x - y + m].end(); ++it) {
          if (ans[it->second] == -1) ans[it->second] = t + y - it->first;
        }
        s2[x - y + m].clear();
        int d = min(x, y);
        x -= d;
        y -= d;
        t += d;
        if (x == 0) dx = 1 - dx;
        if (y == 0) dy = 1 - dy;
      }
    }
  }
  for (int i = 1; i <= k; ++i) {
    printf("%I64d\n", ans[i]);
  }
}
int main() {
  while (~scanf("%d%d%d", &n, &m, &k)) solve();
  return 0;
}
