#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = {1, -1, -1, 1, 0, 0, -1, 1};
int dy2[] = {1, -1, 1, -1, 1, -1, 0, 0};
int kmx[] = {-1, -1, 1, 1, 2, -2, 2, -2};
int kmy[] = {2, -2, 2, -2, -1, -1, 1, 1};
int bishopX[] = {-1, 1, -1, 1};
int bishopY[] = {-1, -1, 1, 1};
class Timer {
 public:
  clock_t T;
  Timer() { T = clock(); }
  ~Timer() {
    fprintf(stderr, "\n%.3f\n", double(clock() - T) / CLOCKS_PER_SEC);
  }
};
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
long long readL() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int N = 1e5 + 5;
int visX[N][4], visY[N][4];
vector<int> v1[4 * N], v2[4 * N];
int n, m, k;
long long ans[N];
pair<int, int> a[N];
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 0; i < k; i++) {
    int x = read();
    int y = read();
    ans[i] = -1;
    v1[x - y + N].push_back(i);
    v2[x + y].push_back(i);
    a[i] = make_pair(x, y);
  }
  int x = 0;
  int y = 0;
  int d = 0;
  long long gt = 0;
  int mn;
  while (1) {
    switch (d) {
      case 0:
        mn = min(n - x, m - y);
        x = x + mn;
        y = y + mn;
        gt += mn;
        break;
      case 1:
        mn = min(x, y);
        x = x - mn;
        y = y - mn;
        gt += mn;
        break;
      case 2:
        mn = min(x, m - y);
        x = x - mn;
        y = y + mn;
        gt += mn;
        break;
      case 3:
        mn = min(n - x, y);
        x = x + mn;
        y = y - mn;
        gt += mn;
        break;
    }
    int dif = x - y + N;
    int sum = x + y;
    if (d == 0 || d == 1)
      for (int i = 0; i < v1[dif].size(); i++) {
        int j = v1[dif][i];
        if (ans[j] == -1) {
          int dddd = abs(x - a[j].first);
          ans[j] = gt - dddd;
        }
      }
    else
      for (int i = 0; i < v2[sum].size(); i++) {
        int j = v2[sum][i];
        if (ans[j] == -1) {
          int dddd = abs(x - a[j].first);
          ans[j] = gt - dddd;
        }
      }
    if (x == 0 && y == 0 || x == 0 && y == m || x == n && y == 0 ||
        x == n && y == m) {
      break;
    }
    if (x == n) {
      if (d == 0)
        d = 2;
      else if (d == 3)
        d = 1;
      continue;
    }
    if (y == m) {
      if (d == 2)
        d = 1;
      else if (d == 0)
        d = 3;
      continue;
    }
    if (x == 0) {
      if (d == 2)
        d = 0;
      else if (d == 1)
        d = 3;
      continue;
    }
    if (y == 0) {
      if (d == 1)
        d = 2;
      else if (d == 3)
        d = 0;
      continue;
    }
  }
  for (int i = 0; i < k; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
