#include<cstdio>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
stack<int> st;
int ch[100010];
vector<pair<int,int>> vt[4];
int main()
{
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
for (int i = 1; i <= k; i++) {
int q, w, e, r;
scanf("%d %d %d %d", &q, &w, &e, &r);
if ((q == 0 || q == n || w == 0 || w == m) && (e == 0 || e == n || r == 0 || r == m)) {
if (q == 0)
vt[0].push_back({ w,i });
else if (w == m)
vt[1].push_back({ q,i });
else if (q == n)
vt[2].push_back({ w,i });
else if (w == 0)
vt[3].push_back({ q,i });
if (e == 0)
vt[0].push_back({ r,i });
else if (r == m)
vt[1].push_back({ e,i });
else if (n == e)
vt[2].push_back({ r,i });
else if (r == 0)
vt[3].push_back({ e,i });
}
}
for (int i = 0; i < 4; i++)
sort(vt[i].begin(), vt[i].end());
for (int i = 2; i < 4; i++)
reverse(vt[i].begin(), vt[i].end());
for (int i = 0; i < 4; i++) {
for (int y = 0; y < vt[i].size(); y++) {
int next = vt[i][y].second;
ch[next]++;
if (ch[next] == 1)
st.push(next);
else {
if (st.top() != next) {
puts("NO");
return 0;
}
else st.pop();
}
}
}
puts("YES");
}