#include <bits/stdc++.h>
using namespace std;
const int64_t M = 1e9 + 7, N = 1e5 + 5;
int64_t a[N][2];
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int64_t n, m, k;
  cin >> n >> m >> k;
  map<pair<int64_t, int64_t>, int64_t> mp;
  for (int64_t i = 0; i < k; i++) cin >> a[i][0] >> a[i][1];
  int64_t flag = 0, x = 0, y = 0, cnt = 1;
  while (1) {
    mp[{x, y}] = cnt;
    int64_t x1 = x, y1 = y;
    if (flag == 0) {
      if (y == m) {
        if ((x - m) >= 0)
          x -= m, y = 0;
        else
          y -= x, x = 0;
      } else if (x == n) {
        if (x - y >= 0)
          x -= y, y = 0;
        else
          y -= n, x = 0;
      } else if (x == 0) {
        if (x + (m - y) <= n)
          x += (m - y), y = m;
        else
          y += n - x, x = n;
      } else {
        if (x + m <= n)
          x += m, y = m;
        else
          y += (n - x), x = n;
      }
      flag = 1;
    } else {
      if (x == n) {
        if ((x - (m - y)) >= 0)
          x -= (m - y), y = m;
        else
          y += n, x = 0;
      } else if (y == m) {
        if (x + m <= n)
          x += m, y = 0;
        else
          y -= (n - x), x = n;
      } else if (x == 0) {
        if (x + y <= n)
          x += y, y = 0;
        else
          y -= n, x = n;
      } else {
        if (x - m >= 0)
          x -= m, y = m;
        else
          y += x, x = 0;
      }
      flag = 0;
    }
    cnt += abs(x - x1);
    if (x == 0 and y == 0) break;
    if (x == 0 and y == m) break;
    if (x == n and y == 0) break;
    if (x == n and y == m) break;
  }
  mp[{x, y}] = cnt;
  for (int64_t i = 0; i < k; i++) {
    int64_t x = a[i][0], y = a[i][1];
    pair<int64_t, int64_t> p1, p2, p3, p4;
    if (x + (m - y) <= n)
      p1.first = x + m - y, p1.second = m;
    else
      p1.first = n, p1.second = y + n - x;
    if (x - y >= 0)
      p2.first = x - y, p2.second = 0;
    else
      p2.first = 0, p2.second = y - x;
    if (x + y <= n)
      p3.first = x + y, p3.second = 0;
    else
      p3.first = n, p3.second = y - (n - x);
    if (x - (m - y) >= 0)
      p4.first = x - (m - y), p4.second = m;
    else
      p4.first = 0, p4.second = y + x;
    int64_t t1 = 0, t2 = 0, t3 = 0, t4 = 0;
    t1 = mp[{p1.first, p1.second}];
    t2 = mp[{p2.first, p2.second}];
    t3 = mp[{p3.first, p3.second}];
    t4 = mp[{p4.first, p4.second}];
    if (t1 != 0 and t2 != 0) {
      if (t3 != 0 and t4 != 0) {
        if (t1 < t3) {
          if (t1 < t2) {
            cout << t1 + abs(x - p1.first) - 1 << "\n";
          } else {
            cout << t2 + abs(x - p2.first) - 1 << "\n";
          }
        } else {
          if (t3 < t4) {
            cout << t3 + abs(x - p3.first) - 1 << "\n";
          } else {
            cout << t4 + abs(x - p4.first) - 1 << "\n";
          }
        }
      } else {
        if (t1 < t2) {
          cout << t1 + abs(x - p1.first) - 1 << "\n";
        } else {
          cout << t2 + abs(x - p2.first) - 1 << "\n";
        }
      }
    } else {
      if (t3 != 0 and t4 != 0) {
        if (t3 < t4) {
          cout << t3 + abs(x - p3.first) - 1 << "\n";
        } else {
          cout << t4 + abs(x - p4.first) - 1 << "\n";
        }
      } else
        cout << -1 << "\n";
    }
  }
}
