#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160000")
using namespace std;
long long first[110000];
std::pair<int, int> coord[110000];
vector<int> sensors[220000][2];
bool vis[220000][2];
const int C = 110000;
int dist(std::pair<int, int> a, int x, int y) { return abs(a.first - x); }
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < (k); i++) {
    first[i] = 5E18;
    cin >> coord[i].first >> coord[i].second;
    int x = coord[i].first;
    int y = coord[i].second;
    sensors[x + y][0].push_back(i);
    sensors[x - y + C][1].push_back(i);
  }
  int x = 0;
  int y = 0;
  int dir = 1;
  n++;
  m++;
  long long tim = 0;
  while (1) {
    if ((x == 0 && y == 0) || (x == n - 1 && y == m - 1)) dir = 1;
    if ((x == 0 && y == m - 1) || (x == n - 1 && y == 0)) dir = 0;
    if (dir == 1 && vis[x - y + C][1]) break;
    if (dir == 0 && vis[x + y][0]) break;
    if (dir == 0) vis[x + y][0] = 1;
    if (dir == 1) vis[x - y + C][1] = 1;
    int cord = x + y;
    if (dir == 1) cord = x - y + C;
    for (int i = 0; i < (sensors[cord][dir].size()); i++) {
      int a = sensors[cord][dir][i];
      first[a] = min(first[a], tim + dist(coord[a], x, y));
    }
    int xn, yn;
    if (dir == 0 && (x == 0 || y == m - 1)) {
      int diff = min(n - 1 - x, y);
      x += diff;
      y -= diff;
      tim += diff;
    } else if (dir == 0 && (x == n - 1 || y == 0)) {
      int diff = min(x, m - 1 - y);
      x -= diff;
      y += diff;
      tim += diff;
    } else if (dir == 1 && (x == 0 || y == 0)) {
      int diff = min(n - 1 - x, m - 1 - y);
      x += diff;
      y += diff;
      tim += diff;
    } else if (dir == 1 && (x == n - 1 || y == m - 1)) {
      int diff = min(x, y);
      x -= diff;
      y -= diff;
      tim += diff;
    }
    dir = 1 - dir;
  }
  for (int i = 0; i < (k); i++) {
    if (first[i] > 2E18)
      cout << -1;
    else
      cout << first[i];
    cout << "\n";
  }
  return 0;
}
