#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

int sqrtN = 512;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketSum;
    
    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, 0);
        bucketSum.assign(K, 0);
    }

    void add(int x, int y){
        data[x] += y;
        bucketSum[x / sqrtN] += y;
    }

    long long getSum(int x, int y){
        long long ans = 0;
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                ans += data[i];
            }
            return ans;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            ans += bucketSum[i];
        }

        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            ans += data[i];
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            ans += data[i];
        }
        return ans;
    }
    
};

int convert_point(int x, int y, int R, int C){
    if(x == R){
        return y;
    }
    if(y == C){
        return C + (R - x);
    }
    if(x == 0){
        return C + R + (C - y);
    }
    return 2 * C + R + x;
}

vector <pair<int, int> > xy;
int main(){
    int R;
    int C;
    int N;
    cin >> R >> C >> N;
    
    
    vector <pair<int, bool> > p_is_smaller;
    map <int, int> to_smaller_p;
    int new_N = 0;
    for(int i = 0; i < N; i++){
        int x1;
        int y1;
        int x2;
        int y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if((x1 != R && x1 != 0 && y1 != C && y1 != 0) || (x2 != R && x2 != 0 && y2 != C && y2 != 0)){
            continue;
        }
        int p1 = convert_point(x1, y1, R, C);
        int p2 = convert_point(x2, y2, R, C);
        new_N++;
        if(p1 < p2){
            p_is_smaller.push_back(make_pair(p1, true));
            p_is_smaller.push_back(make_pair(p2, false));
            to_smaller_p[p2] = p1;
        } else {
            p_is_smaller.push_back(make_pair(p2, true));
            p_is_smaller.push_back(make_pair(p1, false));
            to_smaller_p[p1] = p2;
        }
    }
    SqrtDecomposition sq_smaller(2 * new_N);
    SqrtDecomposition sq_bigger(2 * new_N);
    sort(p_is_smaller.begin(), p_is_smaller.end());
    
    map <int, int> to_smaller_p_ind;
    for(int i = 0; i < p_is_smaller.size(); i++){
        int p = p_is_smaller[i].first;
        bool is_smaller = p_is_smaller[i].second;
        if(is_smaller){
            sq_smaller.add(i, 1);
        } else {
            sq_bigger.add(i, 1);
            auto it = lower_bound(p_is_smaller.begin(), p_is_smaller.end(), make_pair(to_smaller_p[p], true));
            to_smaller_p_ind[i] = distance(p_is_smaller.begin(), it);
        }
    }
    
    /*
    for(int i = 0; i < p_is_smaller.size(); i++){
        cout << p_is_smaller[i].first << " " << p_is_smaller[i].second << endl;
    }
    */
    
    bool yes = true;
    for(int i = 2 * new_N - 1; i >= 0; i--){
        
        if(sq_bigger.data[i] != 1){
            continue;
        }
        int p = to_smaller_p_ind[i];
        int lower_smaller = sq_smaller.getSum(p, i + 1);
        int lower_bigger = sq_bigger.getSum(p, i + 1);
        if(lower_bigger != lower_smaller){
            yes = false;
            break;
        }
        sq_bigger.add(i, -1);
        sq_smaller.add(p, -1);
    }
    
    if(yes){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 14320