/*
solution here

*/

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define nl '\n'
#define sp ' '
using ll = long long;
ll inf = 2e18;
const int N = 2e5+10;
ll arr[N];
void solve()
{
    int n,w;
    cin>>n>>w;
    rep(i,n){
        int a,b,c; cin>>a>>b>>c;
        ++a; ++b;
        arr[a]+=c; arr[b]-=c;
    }
    rep1(i,N-10)
    {
        arr[i]+=arr[i-1];
        if(arr[i]>w)
        {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
int main()
{
    ios::sync_with_stdio(!cin.tie(0));
    // cout<<fixed;
    // cout.precision(12);
    solve();
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define ff first
#define ss second
#define INT_MAX LLONG_MAX
#define pi pair<int,int>
#define pii pair< int, pair<int,int> >
#define all(v) (v).begin(),(v).end()
int parent[200005];
map<int,map<int,int> >m;
void make_set(int v) {
    parent[v] = v;
}
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
    	if(m[a].size() < m[b].size()){
    		swap(a,b);
		}
        parent[b] = a;
        map<int,int > :: iterator it;
        for(it = m[b].begin();  it!= m[b].end() ;it++){
        	m[a][it->ff] += it->ss;
		}
		m[b].clear();
    }
}
void solve(){
	int n,q;
	cin>>n>>q;
	int a[n+5];
	for(int i=1; i<=n ;i++){
		cin>>a[i];
	}
	for(int i=1; i<=n ;i++){
		make_set(i);
		m[i][a[i]] = 1;
	}
	while(q--){
		int x,y,z;
		cin>>x>>y>>z;
		if(x&1){
			union_sets(y,z);
		}else{
			int par = find_set(y);
			int val = m[par][z];
			cout<<val<<endl;
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t;
//	cin>>t;
	t = 1;
	for(int T=1; T<=t ;T++){
		solve();
	}
}