#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, 1, sizeof(p))

#define INF 1000000000

int R, C, N;

vector< pair< int, pair<int, int> > > dots; // id, x, y

// x 小さい順
struct x_less {
    bool operator()(const pair< int, pair<int, int> >& x, const pair< int, pair<int, int> >& y) const {
        return x.second.first < y.second.first;
    }
};
// x 大きい順
struct x_greater {
    bool operator()(const pair< int, pair<int, int> >& x, const pair< int, pair<int, int> >& y) const {
        return x.second.first > y.second.first;
    }
};
// y 小さい順
struct y_less {
    bool operator()(const pair< int, pair<int, int> >& x, const pair< int, pair<int, int> >& y) const {
        return x.second.second < y.second.second;
    }
};
// y 大きい順
struct y_greater {
    bool operator()(const pair< int, pair<int, int> >& x, const pair< int, pair<int, int> >& y) const {
        return x.second.second > y.second.second;
    }
};

bool isExist[100005];
stack<int> st;  // id を保持

int check(int x, int y, int id) {
    if(isExist[id]) {
        if(st.top() != id) {
            //printf("fail! id: %d top: %d\n", id, st.top());
            printf("NO\n");
            return -1;
        } else {
            //printf("pop id: %d top: %d\n", id, st.top());
            st.pop();
        }
    } else {
        isExist[id] = true;
        st.push(id);
        //printf("push: %d (%d, %d)\n", id, x, y);
    }
    return 0;
}

int main()
{
    cin >> R >> C >> N;

    REP(i, N) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        // 両方が外周にくっついている
        if( (x1 == 0 || x1 == R || y1 == 0 || y1 == C) &&
            (x2 == 0 || x2 == R || y2 == 0 || y2 == C) ) {
            dots.push_back(make_pair(i, make_pair(x1, y1)));
            dots.push_back(make_pair(i, make_pair(x2, y2)));
            //printf("id: %d (%d, %d)\n", i, x1, y1);
            //printf("id: %d (%d, %d)\n", i, x2, y2);
        }
    }
    // 外周を回る
    ZERO(isExist);

    sort(dots.begin(), dots.end(), y_less());
    REP(i, dots.size()) {
        int x = dots[i].second.first;
        int y = dots[i].second.second;
        int id = dots[i].first;
        if(x == 0 && y != 0) {
            if(check(x, y, id) != 0) { return 0; }
        }
    }
    sort(dots.begin(), dots.end(), x_less());
    REP(i, dots.size()) {
        int x = dots[i].second.first;
        int y = dots[i].second.second;
        int id = dots[i].first;
        if(y == C && x != 0) {
            if(check(x, y, id) != 0) { return 0; }
        }
    }
    sort(dots.begin(), dots.end(), y_greater());
    REP(i, dots.size()) {
        int x = dots[i].second.first;
        int y = dots[i].second.second;
        int id = dots[i].first;
        if(x == R && y != C) {
            if(check(x, y, id) != 0) { return 0; }
        }
    }
    sort(dots.begin(), dots.end(), x_greater());
    REP(i, dots.size()) {
        int x = dots[i].second.first;
        int y = dots[i].second.second;
        int id = dots[i].first;
        if(y == 0 && x != R) {
            if(check(x, y, id) != 0) { return 0; }
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 4980