#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long inf = 0xfffffffffffffff;
struct node {
  long long x, y;
} ask[maxn];
long long Time[4][maxn];
long long corner[5];
int main() {
  long long n, m, k;
  while (cin >> n >> m >> k) {
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < maxn; ++j) {
        Time[i][j] = inf;
      }
    }
    for (int i = 0; i < k; ++i) {
      cin >> ask[i].x >> ask[i].y;
    }
    int model = 1;
    long long x0 = 0, y0 = 0;
    corner[0] = 0;
    for (int i = 1; i <= 4; ++i) corner[i] = inf;
    long long num = 0;
    while (1) {
      if (model == 1) {
        if (m == y0 + (n - x0)) {
          corner[1] = num + (n - x0);
          break;
        }
        if (m > (y0 + (n - x0))) {
          model = 2;
          num += n - x0;
          Time[1][y0 + (n - x0)] = min(Time[1][y0 + (n - x0)], num);
          y0 = y0 + (n - x0);
          x0 = n;
        } else {
          model = 4;
          num += m - y0;
          Time[2][m + x0 - y0] = min(Time[2][m + x0 - y0], num);
          x0 = m + x0 - y0;
          y0 = m;
        }
      } else if (model == 2) {
        if (m == y0 - (0 - x0)) {
          corner[2] = num + (x0);
          break;
        }
        if (m > y0 - (0 - x0)) {
          model = 1;
          num += x0;
          Time[3][y0 + x0] = min(num, Time[3][y0 + x0]);
          y0 = y0 - (0 - x0);
          x0 = 0;
        } else {
          model = 3;
          num += m - y0;
          Time[2][x0 - m + y0] = min(num, Time[2][x0 - m + y0]);
          x0 = x0 - (m - y0);
          y0 = m;
        }
      } else if (model == 3) {
        if (0 == y0 + (0 - x0)) {
          corner[3] = num + x0;
          break;
        }
        if (0 < y0 + (0 - x0)) {
          model = 4;
          num += x0;
          Time[3][y0 + (0 - x0)] = min(Time[3][y0 + (0 - x0)], num);
          y0 = y0 + (0 - x0);
          x0 = 0;
        } else {
          model = 2;
          num += y0;
          Time[0][x0 - y0] = min(Time[0][x0 - y0], num);
          x0 = x0 - y0;
          y0 = 0;
        }
      } else {
        if (0 == y0 - (n - x0)) {
          corner[4] = num + (n - x0);
          break;
        }
        if (0 < y0 - (n - x0)) {
          model = 3;
          num += n - x0;
          Time[1][y0 - (n - x0)] = min(Time[1][y0 - (n - x0)], num);
          y0 = y0 - (n - x0);
          x0 = n;
        } else {
          model = 1;
          num += y0;
          Time[0][x0 + y0] = min(Time[0][x0 + y0], num);
          x0 = x0 + y0;
          y0 = 0;
        }
      }
    }
    long long ans;
    for (int i = 0; i < k; ++i) {
      ans = inf;
      long long time1, time2, time3, time4;
      x0 = ask[i].x;
      y0 = ask[i].y;
      bool flag1 = false, flag2 = false;
      if (m > (n - x0) + y0) {
        time1 = Time[1][n - x0 + y0];
        flag1 = true;
      } else if (m < (n - x0) + y0) {
        time1 = Time[2][m + x0 - y0];
      } else
        time1 = corner[1];
      if (0 > (0 - x0) + y0) {
        time2 = Time[0][x0 - y0];
        flag2 = true;
      } else if (0 == (0 - x0 + y0))
        time2 = corner[0];
      else
        time2 = Time[3][y0 - x0];
      if (time1 != inf && time1 < time2 && flag1) {
        ans = time1 + (n - x0);
      } else if (time1 != inf && time1 < time2 && (!flag1)) {
        ans = time1 + (m - y0);
      } else if (time2 != inf && flag2) {
        ans = min(ans, time2 + y0);
      } else if (time2 != inf && (!flag2)) {
        ans = min(ans, time2 + x0);
      }
      bool flag3 = false, flag4 = false;
      if (m > -(0 - x0) + y0) {
        time3 = Time[3][y0 + x0];
        flag3 = true;
      } else if (m == -(0 - x0) + y0) {
        time3 = corner[2];
      } else {
        time3 = Time[2][x0 + y0 - m];
      }
      if (0 > -(n - x0) + y0) {
        time4 = Time[0][x0 + y0];
        flag4 = true;
      } else if (0 < -(n - x0) + y0) {
        time4 = Time[1][y0 - (n - x0)];
      } else
        time4 = corner[4];
      if (time3 != inf && time3 < time4 && flag3) {
        ans = min(ans, time3 + x0);
      } else if (time3 != inf && time3 < time4 && !flag3) {
        ans = min(ans, time3 + (m - y0));
      } else if (time4 != inf && flag4) {
        ans = min(ans, time4 + y0);
      } else if (time4 != inf && !flag4) {
        ans = min(ans, time4 + n - x0);
      }
      if (ans == inf)
        puts("-1");
      else
        cout << ans << endl;
    }
  }
  return 0;
}
