#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef _DEBUG
#define show(x)          \
	cerr << #x << " : "; \
	showVal(x)
template <typename T>
void showVal(const T &a) { cerr << a << endl; }
template <typename T>
void showVal(const vector<T> &a) {
	for (const T &v : a) cerr << v << " ";
	cerr << endl;
}
template <typename T>
void showVal(const vector<vector<T>> &a) {
	cerr << endl;
	for (const vector<T> &v : a) showVal(v);
}
#else
#define show(x)
#endif
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m), y(m), z(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	vector<ll> dp(1 << n, 0);
	// 左から見てすでにbit決まっている
	dp[0] = 1;
	for (int bit = 0; bit < 1 << n; bit++) {
		vector<bool> isEx(n, false);
		for (int i = 0; i < n; i++) {
			if ((bit >> i) & 1) isEx[i] = true;
		}
		for (int i = 0; i < n; i++) {
			if (!isEx[i]) {
				vector<int> now;
				for (int j = n - 1; j >= 0; j--) {
					if (isEx[j] || j == i) now.push_back(j + 1);
				}
				bool isOK = true;
				for (int j = 0; j < m; j++) {
					int cnt = 0;
					for (int k = 0; k < min(x[j], (int)now.size()); k++) {
						if (now[k] <= y[j]) cnt++;
					}
					if (cnt > z[j]) {
						isOK = false;
						break;
					}
				}
				if (isOK) {
					dp[bit | (1 << i)] += dp[bit];
				}
			}
		}
	}
	show(dp);
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}
#include<bits/stdc++.h>
    #define ll long long
    #define ld long double
    #define ff first
    #define ss second
    #define eb emplace_back
    #define pb push_back
    #define mp make_pair
    #define all(x) begin(x), end(x)
    #define endl "\n"
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, -1, 1};
    ll dp[100005];
    ll mod = 998244353;
    bool vis[100000];
    using namespace std;
    bool isPrime(ll n) {
      ll j;
      for ( j = 2; j <= sqrt(n); j++) {
        if (n % j == 0) {
          break;
        }
      }
      if (j > sqrt(n)) {
        return 1;
      }
      else {
        return 0;
      }
    }
    ll modexpo(ll a, ll b) {
      ll ans = 1;
      a = a % mod;
      while (b > 0) {
        if ((b & 1) == 1) {
          ans = ((ans % mod) * (a % mod)) % mod;
        }
        b = b >> 1;
        a = ((a % mod) * (a % mod)) % mod;
      }
      return ans;
    }
    ll invmod(ll n) {
      return modexpo(n, mod - 2);
    }
    
    ll comb(ll n, ll r) {
      if (r == 0) {
        return 1;
      }
      ll fact[n + 1];
      fact[0] = 1;
      for (ll i = 1; i <= n; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
      }
      return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) % mod;
    }
    ll gcd(ll a, ll b) {
      if (a == 0) {
        return b;
      }
      return gcd(b % a, a);
    }
    ll lcm(ll a, ll b) {
      return (a * b) / gcd(a, b);
    }
    void dfs(ll i, vector<ll>adj[], bool visited[]) {
      visited[i] = 1;
      for (auto j : adj[i]) {
        if (visited[j] == 0) {
          dfs(j, adj, visited);
        }
      }
    }
    bool sortbysecdesc(const pair<int, int> &a, const pair<int, int> &b)
    {
      return a.second > b.second;
    }
    void solve(ll k) {
    ll n,m,ti;
    cin>>n>>m>>ti;
    ll n1=n;
    bool ok=0;
    ll pr=0;
    while(m--){
        ll a,b;
        cin>>a>>b;
        n-=(a-pr);
        if(n<=0){
            ok=1;
        }
        n+=b-a;
        n=min(n,n1);
        pr=b;
    }
    n-=(ti-pr);
    if(n<=0){
        ok=1;
    }
    if(ok==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    }
    
    int main() {
    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
    #endif
    
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll t = 1;
     // cin >> t;
      ll k = 1;
      while (k <= t) {
        solve(k);
        k++;
      }
      return 0;
    }