#include <bits/stdc++.h>
using namespace std;

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

int R, C, N;
int side(int x, int y) {
    if(x == 0) return 1; // top
    if(y == C) return 2; // right
    if(x == R) return 3; // bottom
    if(y == 0) return 4; // left
    return 0;
}

//   pos num
vector<pair<int,int>> nt, nb, nl, nr;

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
    //*
    scanf("%d%d%d",&R,&C,&N);
    nt.reserve(N*2); nb.reserve(N); nl.reserve(N); nr.reserve(N);

    times(N, i) {
        int X1, Y1, X2, Y2;
        scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
        int s1 = side(X1, Y1), s2 = side(X2, Y2);
        if(s1 && s2) {
            switch(s1) {
                case 1: nt.push_back({Y1, i}); break;
                case 2: nr.push_back({X1, i}); break;
                case 3: nb.push_back({Y1, i}); break;
                case 4: nl.push_back({X1, i}); break;
                default: if(debug) cout << "assert(s1)\n";
            }
            switch(s2) {
                case 1: nt.push_back({Y2, i}); break;
                case 2: nr.push_back({X2, i}); break;
                case 3: nb.push_back({Y2, i}); break;
                case 4: nl.push_back({X2, i}); break;
                default: if(debug) cout << "assert(s2)\n";
            }
        }
    }
    sort(nt.begin(), nt.end());
    sort(nr.begin(), nr.end());
    sort(nb.begin(), nb.end());
    sort(nl.begin(), nl.end());
    if(debug) {
        times (nt.size(), i) cout << nt[i].second sp; cout ln;
        times (nr.size(), i) cout << nr[i].second sp; cout ln;
        rtimes(nb.size(), i) cout << nb[i].second sp; cout ln;
        rtimes(nl.size(), i) cout << nl[i].second sp; cout ln;
    }
    times (nr.size(), i) nt.push_back(nr[i]);
    rtimes(nb.size(), i) nt.push_back(nb[i]);
    rtimes(nl.size(), i) nt.push_back(nl[i]);
    int s = nt.size();
    /*/
    int s; scanf("%d",&s);
    nt.clear(); times(s, i) {int k;scanf("%d",&k);nt.push_back({0,k});}
    //*/
    if(debug && s % 2 == 1) {
        cout << "assert(" << s << " % 2 == 0)\n";
    }
    if(debug) {
        times(s, i) cout << nt[i].second sp; cout ln;
    }
    stack<int> pyon; pyon.push(-1);
    times(s, i) {
        if(pyon.top() == nt[i].second) pyon.pop();
        else pyon.push(nt[i].second);
    }
    if(pyon.size() == 1)
        cout << "YES\n";
    else
        cout << "NO\n";

    /*
    if(not nt.empty()) {
        int i = 0;
        if(nt[0].second != nt[s-1].second) {
            while(nt[i].second != nt[i+1].second) ++i;
            ++i;
        }
        times(s/2, j) {
            if(nt[(i+j)%s].second == nt[(i+j)])
            if(nt[(i+j)%s].second != nt[(i-1-j+s)%s].second) {
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    */

    return 0;
}


Measured memory_bytes: 3584