#include<ctime>
#include<cstdio>
#include<cctype>
#define ll long long
using namespace std;
const ll N=2e6+7;
const ll p=1e9+7;
ll read(){
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while(isdigit(c)){
		x=x*10+f*(c-48);
		c=getchar();
	}
	return x;
}
ll n,m,k,jc[N],inv[N];
ll C(ll i,ll j){
	if(j>i)
		return 0;
	return jc[i]*inv[j]%p*inv[i-j]%p;
}
ll HgS(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)
			res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return res;
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	m=read();
	k=read();
	jc[0]=1;
	for(ll i=1;i<=n+m;++i)
		jc[i]=jc[i-1]*i%p;
	inv[n+m]=HgS(jc[n+m],p-2);
	for(ll i=n+m-1;~i;--i)
		inv[i]=inv[i+1]*(i+1)%p;
	if(n>m+k)
		puts("0");
	else
		printf("%lld",(C(n+m,n)-C(n+m,m+k+1)+p)%p);
	//--------
	fprintf(stderr,"%0.3lfs",1.0*(clock()-t1)/CLOCKS_PER_SEC);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N;
    cin >> N;
    vector<pair<double, double>> A(N);
    REP(i, N) {
        int t;
        double l, r;
        cin >> t >> l >> r;
        if (t == 2) {
            r -= 0.1;
        } else if (t == 3) {
            l += 0.1;
        } else if (t == 4) {
            r -= 0.1;
            l += 0.1;
        }
        A[i] = {l, r};
    }
    int ans = 0;
    REP(i, N) {
        FOR(j, i + 1, N) {
            // 共通区間（左端の最大値 <= 右端の最小値）
            ans +=
                (max(A[i].first, A[j].first) <= min(A[i].second, A[j].second));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}
