#include <bits/stdc++.h>
#pragma comment(linker, "/stack:225450978")
#pragma GCC optimize("Ofast")
using namespace std;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9,
                  Gold = ((1 + sqrt(5)) / 2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
long long keyCount = sizeof(keymod) / sizeof(long long);
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcountll(s);
}
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
string cppstr_infile = "FILE.IN";
string cppstr_outfile = "FILE.OUT";
long long n, m, k, offset;
vector<pair<long long, long long>> Points;
vector<vector<vector<long long>>> PointsinLine;
void Input() {
  cin >> n >> m >> k;
  Points.resize(k);
  PointsinLine.resize(2, vector<vector<long long>>((n + m) * 2 + 2));
  offset = n + m;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    Points[i] = {x, y};
    PointsinLine[0][x + y + offset].push_back(i);
    PointsinLine[1][x - y + offset].push_back(i);
  }
}
void Solve() {
  vector<long long> FirstMet(k, -1);
  vector<vector<bool>> vis(2, vector<bool>((n + m) * 2 + 2, false));
  long long x = 0, y = 0, dx = 1, dy = 1, Time = 0;
  queue<pair<long long, long long>> Q;
  Q.push(make_pair(1LL, offset + 0));
  vis[1][offset + 0] = true;
  while (!Q.empty()) {
    long long LineType = Q.front().first, LineID = Q.front().second;
    Q.pop();
    for (auto id : PointsinLine[LineType][LineID]) {
      if (FirstMet[id] != -1) continue;
      long long delta = (Points[id].first - x) / dx;
      FirstMet[id] = Time + delta;
    }
    long long stepx = 0, stepy = 0;
    if (dx == +1)
      stepx = n - x;
    else
      stepx = x;
    if (dy == +1)
      stepy = m - y;
    else
      stepy = y;
    long long step = min(stepx, stepy);
    x += step * dx;
    y += step * dy;
    Time += step;
    if ((x == n && dx == 1) || (x == 0 && dx == -1)) dx = -dx;
    if ((y == m && dy == 1) || (y == 0 && dy == -1)) dy = -dy;
    LineType = (dx == dy);
    LineID = 0;
    if (LineType == 1)
      LineID = x - y + offset;
    else
      LineID = x + y + offset;
    if (!vis[LineType][LineID]) {
      vis[LineType][LineID] = true;
      Q.push(make_pair(LineType, LineID));
    }
  }
  for (auto x : FirstMet) cout << x << '\n';
}
int main(int argc, char* argv[]) {
  ControlIO(argc, argv);
  Input();
  TimerStart();
  Solve();
  TimerStop();
  return 0;
}
void ControlIO(int argc, char* argv[]) {
  char* infile = new char[cppstr_infile.size() + 1];
  char* outfile = new char[cppstr_outfile.size() + 1];
  strcpy(infile, cppstr_infile.c_str());
  strcpy(outfile, cppstr_outfile.c_str());
}
void TimerStart() {}
void TimerStop() {}
void Exit() {
  TimerStop();
  exit(0);
}
