#include <bits/stdc++.h>
using namespace std;
int l[200005], r[200005], n, m, k;
long long _time, timel[200005], timer[200005], dirl[200005], dirr[200005];
void build() {
  int dir = 0;
  int x = 0, y = 0;
  while (1) {
    if (dir == 0) {
      int dis1 = n - x;
      int dis2 = m - y;
      if (dis1 < dis2) {
        x += dis1;
        y += dis1;
        r[y + n - x] = 1;
        if (_time < timer[y + n - x]) {
          timer[y + n - x] = _time;
          dirr[y + n - x] = 0;
        }
        _time += dis1;
        dir = 3;
      } else if (dis1 > dis2) {
        x += dis2;
        y += dis2;
        r[y + n - x] = 1;
        if (_time < timer[y + n - x]) {
          timer[y + n - x] = _time;
          dirr[y + n - x] = 0;
        }
        _time += dis2;
        dir = 1;
      } else {
        x += dis1;
        y += dis1;
        r[y + n - x] = 1;
        if (_time < timer[y + n - x]) {
          timer[y + n - x] = _time;
          dirr[y + n - x] = 0;
        }
        _time += dis1;
        break;
      }
    } else if (dir == 1) {
      int dis1 = n - x;
      int dis2 = y;
      if (dis1 < dis2) {
        x += dis1;
        y -= dis1;
        l[x + y] = 1;
        if (_time < timel[x + y]) {
          timel[x + y] = _time;
          dirl[x + y] = 1;
        }
        _time += dis1;
        dir = 2;
      } else if (dis1 > dis2) {
        x += dis2;
        y -= dis2;
        l[x + y] = 1;
        if (_time < timel[x + y]) {
          timel[x + y] = _time;
          dirl[x + y] = 1;
        }
        _time += dis2;
        dir = 0;
      } else {
        x += dis1;
        y -= dis1;
        l[x + y] = 1;
        if (_time < timel[x + y]) {
          timel[x + y] = _time;
          dirl[x + y] = 1;
        }
        _time += dis1;
        break;
      }
    } else if (dir == 2) {
      int dis1 = x;
      int dis2 = y;
      if (dis1 < dis2) {
        x -= dis1;
        y -= dis1;
        r[y + n - x] = 1;
        if (_time < timer[y + n - x]) {
          timer[y + n - x] = _time;
          dirr[y + n - x] = 2;
        }
        _time += dis1;
        dir = 1;
      } else if (dis1 > dis2) {
        x -= dis2;
        y -= dis2;
        r[y + n - x] = 1;
        if (_time < timer[y + n - x]) {
          timer[y + n - x] = _time;
          dirr[y + n - x] = 2;
        }
        _time += dis2;
        dir = 3;
      } else {
        x -= dis1;
        y -= dis1;
        r[y + n - x] = 1;
        if (_time < timer[y + n - x]) {
          timer[y + n - x] = _time;
          dirr[y + n - x] = 2;
        }
        _time += dis1;
        break;
      }
    } else if (dir == 3) {
      int dis1 = x;
      int dis2 = m - y;
      if (dis1 < dis2) {
        x -= dis1;
        y += dis1;
        l[x + y] = 1;
        if (_time < timel[x + y]) {
          timel[x + y] = _time;
          dirl[x + y] = 3;
        }
        _time += dis1;
        dir = 0;
      } else if (dis1 > dis2) {
        x -= dis2;
        y += dis2;
        l[x + y] = 1;
        if (_time < timel[x + y]) {
          timel[x + y] = _time;
          dirl[x + y] = 3;
        }
        _time += dis2;
        dir = 2;
      } else {
        x -= dis1;
        y += dis1;
        l[x + y] = 1;
        if (_time < timel[x + y]) {
          timel[x + y] = _time;
          dirl[x + y] = 3;
        }
        _time += dis1;
        break;
      }
    }
  }
}
int main() {
  for (int i = 0; i <= 200004; i++) timel[i] = timer[i] = (1ll << 60);
  scanf("%d %d %d", &n, &m, &k);
  build();
  while (k--) {
    int x, y;
    scanf("%d %d", &x, &y);
    long long res = (1ll << 60);
    if (l[x + y]) {
      if (dirl[x + y] == 1)
        res = min(res, timel[x + y] + min(m - y, x));
      else if (dirl[x + y] == 3)
        res = min(res, timel[x + y] + min(y, n - x));
    }
    if (r[y + n - x]) {
      if (dirr[y + n - x] == 0)
        res = min(res, timer[y + n - x] + min(y, x));
      else if (dirr[y + n - x] == 2)
        res = min(res, timer[y + n - x] + min(n - x, m - y));
    }
    if (res == (1ll << 60))
      printf("-1\n");
    else
      printf("%lld\n", res);
  }
}
