#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, q;
    cin >> n >> m >> q;

    vector<vector<int>> arr(n+1, vector<int>(m+1, -1));

    int x = 0, y = 0;
    int dx = 1, dy = 1;
    int t = 0;
    
    while (true){
        t++;
        x += dx;
        y += dy;

        if( (x == 0 || x == n) && (y == 0 || y == m)){
            if(arr[x][y] == -1){
                arr[x][y] = t;
            }
            break;
        }

        if(arr[x][y] == -1){
            arr[x][y] = t;
        }

        if(x == 0 || x == n){
            dx *= -1;
        }
        if(y == 0 || y == m){
            dy *= -1;
        }
    }
    
    while(q--){
        int qx, qy;
        cin >> qx >> qy;
        if(qx <0 || qx >n || qy <0 || qy >m){
            cout << "-1\n";
            continue;
        }
        cout << arr[qx][qy] << "\n";
    }
}