#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep1(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>

namespace is_stl_container_impl
{
template <typename T>
struct is_stl_container : false_type {
};
template <typename T, size_t N>
struct is_stl_container<array<T, N>> : true_type {
};
template <typename... Args>
struct is_stl_container<vector<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<deque<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<list<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<forward_list<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<set<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<multiset<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<map<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<multimap<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<unordered_set<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<unordered_multiset<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<unordered_map<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<unordered_multimap<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<stack<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<queue<Args...>> : true_type {
};
template <typename... Args>
struct is_stl_container<priority_queue<Args...>> : true_type {
};
}  // namespace is_stl_container_impl

//type trait to utilize the implementation type traits as well as decay the type
template <typename T>
struct is_stl_container {
    static constexpr bool const value = is_stl_container_impl::is_stl_container<decay_t<T>>::value;
};

template <typename T>
typename enable_if<is_stl_container<T>::value, ostream&>::type operator<<(ostream& os, const T& container)
{
    os << "[";
    for (const auto& p : container) {
        os << p << ",";
    }
    os << "]";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


using ll = long long;
constexpr ll MOD = 1000000007;

template <typename T>
constexpr T INF = numeric_limits<T>::inf() / 100;

ll r, c;


bool on(const pair<ll, ll>& p)
{
    return (p.first == 0 or p.first == r or p.second == 0 or p.second == c);
}

int d(const pair<ll, ll>& p)
{
    if (p.first == 0) {
        return p.second;
    } else if (p.first == r) {
        return r + c + c - p.second;
    }

    if (p.second == 0) {
        return r + r + c + c - p.first;
    } else if (p.second == c) {
        return c + p.first;
    }
}

bool comp(const pair<ll, ll>& p1, const pair<ll, ll>& p2)
{
    return (p1.first < p2.first) ? true : (p1.first == p2.first) ? (p1.second > p2.second) : false;
}

int main()
{
    int n;
    cin >> r >> c >> n;
    vector<pair<ll, int>> dist;
    rep(i, n)
    {
        pair<ll, ll> p[2];
        cin >> p[0].first >> p[0].second >> p[1].first >> p[1].second;
        if (on(p[0]) and on(p[1])) {
            ll di[2] = {d(p[0]), d(p[1])};

            sort(di, di + 2);
            dist.pb(mp(di[0], i));
            dist.pb(mp(di[1], i + n));
        }
    }
    sort(dist.begin(), dist.end(), comp);
    //    show(dist);
    stack<int> st;
    for (int i = 0; i < dist.size(); i++) {
        const int pos = dist[i].second;
        if (pos >= n) {
            if (st.empty() or st.top() != pos - n) {
                cout << "NO" << endl;
                return 0;
            } else {
                st.pop();
            }
        } else {
            st.push(pos);
        }
    }
    cout << "YES" << endl;


    return 0;
}


Measured memory_bytes: 6384