#include <iostream>
#include <algorithm>
typedef long long ll;
typedef double lf;
// #define DEBUG 1
struct IO
{
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
char buf[MAXSIZE], *p1, *p2;
char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
IO() : p1(buf), p2(buf), pp(pbuf) {}
~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
#endif
#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
#define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')
template <typename T>
void Read(T &x)
{
#if DEBUG
std::cin >> x;
#else
bool sign = 0; char ch = gc(); x = 0;
for (; !isdigit(ch); ch = gc())
if (ch == '-') sign = 1;
for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
if (sign) x = -x;
#endif
}
void Read(char *s)
{
#if DEBUG
std::cin >> s;
#else
char ch = gc();
for (; blank(ch); ch = gc());
for (; !blank(ch); ch = gc()) *s++ = ch;
*s = 0;
#endif
}
void Read(char &c) {for (c = gc(); blank(c); c = gc());}
void Push(const char &c)
{
#if DEBUG
putchar(c);
#else
if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
*pp++ = c;
#endif
}
template <typename T>
void Write(T x)
{
if (x < 0) x = -x, Push('-');
static T sta[35];
int top = 0;
do sta[top++] = x % 10, x /= 10; while (x);
while (top) Push(sta[--top] ^ 48);
}
template <typename T>
void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)
using namespace std;
const int MAXN = 1e5 + 10;
int n, m, t;
struct Data
{
int l, r;
bool operator < (const Data u) const {return l < u.l;}
};
vector <Data> a[MAXN << 1], b;
int main()
{
#if DEBUG
#else
ios::sync_with_stdio(0), cin.tie(0);
#endif
Read(n), Read(m), Read(t);
if (m > 2 * t + 1) {cout << "NO\n"; return 0;}
for (int i = 1, l, r, x; i <= t; i++) Read(l), Read(r), Read(x), a[x].push_back(Data{l, r});
ll sum1 = 0, sum2 = 0;
for (int i = 1; i <= m; i++)
{
sort(a[i].begin(), a[i].end());
if (!a[i].size()) {sum1 += n, sum2 += n - 1; continue;}
int pre = a[i][0].l, nxt = a[i][0].r; ll cur1 = n, cur2 = n - 1;
for (int j = 0; j < a[i].size(); j++)
{
if (a[i][j].l <= nxt) nxt = max(nxt, a[i][j].r);
else
{
cur1 -= nxt - pre + 1, cur2 -= nxt - pre + (pre != 1) + (nxt != n);
pre = a[i][j].l, nxt = a[i][j].r;
}
}
cur1 -= nxt - pre + 1, cur2 -= nxt - pre + (pre != 1) + (nxt != n);
sum1 += cur1, sum2 += cur2;
}
// cout << sum1 << " " << sum2 << "\n";
for (int i = 2; i <= m; i++)
{
b.clear();
for (auto x : a[i - 1]) b.push_back(x);
for (auto x : a[i]) b.push_back(x);
sort(b.begin(), b.end());
if (!b.size()) {sum2 += n; continue;}
int pre = b[0].l, nxt = b[0].r; ll cur = n;
for (int j = 0; j < b.size(); j++)
{
// cout << b[j].l << " " << b[j].r << "\n";
if (b[j].l <= nxt) nxt = max(nxt, b[j].r);
else
{
cur -= nxt - pre + 1;
pre = b[j].l, nxt = b[j].r;
}
}
cur -= nxt - pre + 1;
sum2 += cur;
}
// cout << sum1 << " " << sum2 << "\n";
if (sum1 == sum2 + 1) cout << "YES\n";
else cout << "NO\n";
return 0;
}