#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=20;

int n, m, q, u, v, x, y, t, a, b, ans;
int L[MAXN], R[MAXN], par[MAXN];
int typ[MAXN], A[MAXN], B[MAXN];
vector<int> comp;

int getpar(int x){
	if (par[x]==x) return x;
	return par[x]=getpar(par[x]);
}
void join(int x, int y){
//	debug2(x, y)
	x=getpar(x);
	y=getpar(y);
	if (x==y) return ;
	L[x]=min(L[x], L[y]);
	R[x]=max(R[x], R[y]);
	par[y]=x;
}

struct SEGMENT1{
	set<pii> st[MAXN];
	pii seg[MAXN<<1];
	SEGMENT1(){
		memset(seg, 63, sizeof(seg));
	}
	void relax(int pos){
		seg[pos+MAXN]=(st[pos].empty()?pii(inf, inf):(*st[pos].begin()));
		for (pos+=MAXN; pos>1; pos>>=1) seg[pos>>1]=min(seg[pos], seg[pos^1]);
	}
	pii Get(int l, int r){
		pii res={inf, -1};
		for (l+=MAXN, r+=MAXN; l<r; l>>=1, r>>=1){
			if (l&1) res=min(res, seg[l++]);
			if (r&1) res=min(res, seg[--r]);
		}
		return res;
	}
	void add(int l, int r, int id){
		st[r].insert({l, id});
		relax(r);
	}
	void rem(int l, int r, int id){
		st[r].erase({l, id});
		relax(r);
	}
} seg1;
struct SEGMENT2{
	set<pii> st[MAXN];
	pii seg[MAXN<<1];
	SEGMENT2(){
		memset(seg, -63, sizeof(seg));
	}
	void relax(int pos){
		seg[pos+MAXN]=(st[pos].empty()?pii(inf, -inf):(*st[pos].begin()));
		seg[pos+=MAXN].first*=-1;
		for (; pos>1; pos>>=1) seg[pos>>1]=max(seg[pos], seg[pos^1]);
	}
	pii Get(int l, int r){
		pii res={-inf, -1};
		for (l+=MAXN, r+=MAXN; l<r; l>>=1, r>>=1){
			if (l&1) res=max(res, seg[l++]);
			if (r&1) res=max(res, seg[--r]);
		}
		return res;
	}
	void add(int l, int r, int id){
		st[l].insert({-r, id});
		relax(l);
	}
	void rem(int l, int r, int id){
		st[l].erase({-r, id});
		relax(l);
	}
} seg2;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>q;
	for (int i=1; i<=q; i++){
		cin>>typ[i]>>A[i]>>B[i];
		if (typ[i]==1){
			comp.pb(A[i]);
			comp.pb(B[i]);
		}
	}
	sort(all(comp));
	comp.resize(unique(all(comp))-comp.begin());
	m=comp.size();
	for (int i=1; i<=q; i++){
		if (typ[i]==2){
			x=getpar(A[i]);
			y=getpar(B[i]);
			if (x==y || (L[y]<=L[x] && R[x]<=R[y])) cout<<"YES\n";
			else cout<<"NO\n";
			continue ;
		}
		n++;
		par[n]=n;
		L[n]=A[i]=lower_bound(all(comp), A[i])-comp.begin();
		R[n]=B[i]=lower_bound(all(comp), B[i])-comp.begin();
		while (1){
			int id=seg1.Get(B[i]+1, m).second;
			if (id<0 || id>n || B[i]<=L[id]) break ;
			seg1.rem(L[id], R[id], id);
			seg2.rem(L[id], R[id], id);
			join(n, id);
		}
		while (1){
			int id=seg2.Get(0, A[i]).second;
			if (id<0 || id>n || R[id]<=A[i]) break ;
			seg1.rem(L[id], R[id], id);
			seg2.rem(L[id], R[id], id);
			join(n, id);
		}
		seg1.add(L[n], R[n], n);
		seg2.add(L[n], R[n], n);
	}

	return 0;
}
/*
5
1 1 5
1 5 11
2 1 2
1 2 9
2 1 2

*/


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[200001];
void merge(int root,int l,int r,int e,int x){
	for(auto it=vec[root].begin();it!=vec[root].end();++it){
		int tem=find(*it);
		if(tem==x)continue;
		f[tem]=x;
		L[x]=min(L[x],L[tem]);
		R[x]=max(R[x],R[tem]);
	}
	if(!vec[root].empty())vec[root].clear(),vec[root].push_back(x);
	if(l==r)return;
	if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
	else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
	if(el>er)return;
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		vec[root].push_back(x);
		return;
	}
	add(root<<1,l,(l+r)>>1,el,er,x);
	add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
		if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
	}
	std::sort(orig+1,orig+top+1);
	top=std::unique(orig+1,orig+top+1)-orig-1;
	for(int i=1,x,y;i<=n;i++){
		if(query[i][0]==1){
			++cnt;
			x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
			y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
			L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
			merge(1,1,top,x,cnt);
			merge(1,1,top,y,cnt);
			add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
		}
		else{
			y=find(query[i][2]);
			x=query[i][1];
			if(find(x)==y||(Ol[x]<L[y]&&Or[x]>R[y]))puts("YES");
			else puts("NO");
		}
	}
}


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[800001];
void merge(int root,int l,int r,int e,int x){
	for(auto it=vec[root].begin();it!=vec[root].end();++it){
		int tem=find(*it);
		if(tem==x)continue;
		f[tem]=x;
		L[x]=min(L[x],L[tem]);
		R[x]=max(R[x],R[tem]);
	}
	if(!vec[root].empty())vec[root].clear(),vec[root].push_back(x);
	if(l==r)return;
	if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
	else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
	if(el>er)return;
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		vec[root].push_back(x);
		return;
	}
	add(root<<1,l,(l+r)>>1,el,er,x);
	add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
		if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
	}
	std::sort(orig+1,orig+top+1);
	top=std::unique(orig+1,orig+top+1)-orig-1;
	for(int i=1,x,y;i<=n;i++){
		if(query[i][0]==1){
			++cnt;
			x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
			y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
			L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
			merge(1,1,top,x,cnt);
			merge(1,1,top,y,cnt);
			add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
		}
		else{
			y=find(query[i][2]);
			x=query[i][1];
			if(find(x)==y||(L[y]<Ol[x]&&R[y]>Ol[x])||(L[y]<Or[x]&&R[y]>Or[x]))puts("YES");
			else puts("NO");
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 3;
const int infint = (int)2e9;
const ll inf = (ll)2e18;
vector<int> seg[4 * MAXN], vec;
int n, t[MAXN], a[MAXN], b[MAXN], pos[MAXN], par[MAXN], sz, l[MAXN], r[MAXN];
int get_par(int u)
{
	return par[u] < 0 ? u : par[u] = get_par(par[u]);
}
void merge(int u, int v)
{
	u = get_par(u);
	v = get_par(v);
	if (u == v)
		return;
	if(par[u] > par[v])
		swap(par[u], par[v]);

	par[v] = u;
	l[u] = min(l[u], l[v]);
	r[u] = max(r[u], r[v]);
}

void update(int u, int x, int id = 1, int st = 0, int en = sz)
{
	for (auto v: seg[id])
		merge(u, v);
	seg[id].clear();
	if (en - st == 1)
		return;
	int mid = st + en >> 1;
	if (x < mid)
		update(u, x, id << 1, st, mid);
	else
		update(u, x, id << 1 | 1, mid, en);
}

void add(int u, int id = 1, int st = 0, int en = sz)
{
	if (r[u] <= st || en <= l[u] + 1)
		return;
	if (l[u] + 1 <= st && en <= r[u])
		return seg[id].push_back(u);
	int mid = st + en >> 1;
	add(u, id << 1, st, mid);
	add(u, id << 1 | 1, mid, en);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t[i] >> a[i] >> b[i];
		if (t[i] == 1)
		{
			par[i] = -1;
			vec.push_back(a[i]);
			vec.push_back(b[i]);
		}
	}
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	sz = vec.size();

	for (int i = 0, j = 0; i < n; i++)
		if (t[i] == 1)
		{
			l[i] = a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
			r[i] = b[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
			update(i, a[i]), update(i, b[i]), add(pos[++j] = i);
		}
		else
		{
			int u = get_par(pos[a[i]]), v = get_par(pos[b[i]]);
			cout << ((l[v] <= l[u] && r[u] <= r[v]) ? "YES" : "NO") << "\n";
		}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 3;
const int infint = (int)2e9;
const ll inf = (ll)2e18;
vector<int> seg[4 * MAXN], vec;
int n, t[MAXN], a[MAXN], b[MAXN], pos[MAXN], par[MAXN], sz, l[MAXN], r[MAXN];
int get_par(int u)
{
	return par[u] < 0 ? u : par[u] = get_par(par[u]);
}
void merge(int u, int v)
{
	u = get_par(u);
	v = get_par(v);
	if (u == v)
		return;
	if(par[u] > par[v])
		swap(par[u], par[v]);

	par[v] = u;
	l[u] = min(l[u], l[v]);
	r[u] = max(r[u], r[v]);
}

void update(int u, int x, int id = 1, int st = 0, int en = vec.size() << 1)
{
	for (auto v: seg[id])
		merge(u, v);
	seg[id].clear();
	if (en - st == 1)
		return;
	int mid = st + en >> 1;
	if (x < mid)
		update(u, x, id << 1, st, mid);
	else
		update(u, x, id << 1 | 1, mid, en);
}

void add(int u, int id = 1, int st = 0, int en = vec.size() << 1)
{
	if (r[u] <= st || en <= l[u] + 1)
		return;
	if (l[u] + 1 <= st && en <= r[u])
		return seg[id].push_back(u);
	int mid = st + en >> 1;
	add(u, id << 1, st, mid);
	add(u, id << 1 | 1, mid, en);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t[i] >> a[i] >> b[i];
		if (t[i] == 1)
		{
			par[i] = -1;
			vec.push_back(a[i]);
			vec.push_back(b[i]);
		}
	}
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	sz = vec.size();

	for (int i = 0, j = 0; i < n; i++)
		if (t[i] == 1)
		{
			l[i] = a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
			r[i] = b[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
			update(i, a[i]), update(i, b[i]), add(pos[++j] = i);
		}
		else
		{
			int u = get_par(pos[a[i]]), v = get_par(pos[b[i]]);
			cout << ((l[v] <= l[u] && r[u] <= r[v]) ? "YES" : "NO") << "\n";
		}
}


#include<bits/stdc++.h>
using namespace std;
#define lc (p<<1)
#define rc ((p<<1)|1)
const int N=100010;
class dsu
{
	public:
		int fa[N],L[N],R[N];
		void init(int n)
		{
			for(int i=1;i<=n;i++)fa[i]=i;
		}
		inline int getf(int x)
		{
			return x==fa[x]?x:fa[x]=getf(fa[x]);
		}
		inline void merge(int x,int y)
		{
			x=getf(x);y=getf(y);
			if(x==y)return;
			fa[x]=y;
			L[y]=min(L[y],L[x]);
			R[y]=max(R[y],R[x]);
		}
}d;
class sgt
{
	public:
		vector<int> tag[N<<3];
		void merge(int p,int l,int r,int pos,int id)
		{
			while(!tag[p].empty())
			{
				d.merge(tag[p].back(),id);
				tag[p].pop_back();
			}
			if(l==r)return;
			int mid=(l+r)>>1;
			if(pos<=mid)merge(lc,l,mid,pos,id);
			else merge(rc,mid+1,r,pos,id);
		}
		void pushtag(int p,int l,int r,int ql,int qr,int id)
		{
			if(ql<=l&&r<=qr)
			{
				tag[p].push_back(id);
				return;
			}
			int mid=(l+r)>>1;
			if(ql<=mid)pushtag(lc,l,mid,ql,qr,id);
			if(qr>mid)pushtag(rc,mid+1,r,ql,qr,id);
		}
}T;
int n,opt[N],l[N],r[N],pos[N];
vector<int> ls;
int main()
{
	scanf("%d",&n);
	d.init(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&opt[i],&l[i],&r[i]);
		if(opt[i]==1)
		{
			ls.push_back(l[i]);
			ls.push_back(r[i]);
		}
	}
	sort(ls.begin(),ls.end());
	ls.erase(unique(ls.begin(),ls.end()),ls.end());
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(opt[i]==1)
		{
			cnt++;
			pos[cnt]=i;
			l[i]=lower_bound(ls.begin(),ls.end(),l[i])-ls.begin();
			r[i]=lower_bound(ls.begin(),ls.end(),r[i])-ls.begin();
			d.L[cnt]=l[i];
			d.R[cnt]=r[i];
			T.merge(1,0,ls.size()-1,l[i],cnt);
			T.merge(1,0,ls.size()-1,r[i],cnt);
			if(l[i]+1<r[i])T.pushtag(1,0,ls.size()-1,d.L[cnt]+1,d.R[cnt]-1,cnt);
		}
		else
		{
			int p=d.getf(r[i]);
			if(d.getf(l[i])==p||(d.L[p]<=l[pos[l[i]]]&&r[pos[l[i]]]<d.R[p]))puts("YES");
			else puts("NO");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lc (p<<1)
#define rc ((p<<1)|1)
const int N=100010;
class dsu
{
	public:
		int fa[N],L[N],R[N];
		void init(int n)
		{
			for(int i=1;i<=n;i++)fa[i]=i;
		}
		inline int getf(int x)
		{
			return x==fa[x]?x:fa[x]=getf(fa[x]);
		}
		inline void merge(int x,int y)
		{
			x=getf(x);y=getf(y);
			if(x==y)return;
			fa[x]=y;
			L[y]=min(L[y],L[x]);
			R[y]=max(R[y],R[x]);
		}
}d;
class sgt
{
	public:
		vector<int> tag[N<<3];
		void merge(int p,int l,int r,int pos,int id)
		{
			while(!tag[p].empty())
			{
				d.merge(tag[p].back(),id);
				tag[p].pop_back();
			}
			if(l==r)return;
			int mid=(l+r)>>1;
			if(pos<=mid)merge(lc,l,mid,pos,id);
			else merge(rc,mid+1,r,pos,id);
		}
		void pushtag(int p,int l,int r,int ql,int qr,int id)
		{
			if(ql<=l&&r<=qr)
			{
				tag[p].push_back(id);
				return;
			}
			int mid=(l+r)>>1;
			if(ql<=mid)pushtag(lc,l,mid,ql,qr,id);
			if(qr>mid)pushtag(rc,mid+1,r,ql,qr,id);
		}
}T;
int n,opt[N],l[N],r[N],pos[N];
vector<int> ls;
int main()
{
	scanf("%d",&n);
	d.init(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&opt[i],&l[i],&r[i]);
		if(opt[i]==1)
		{
			ls.push_back(l[i]);
			ls.push_back(r[i]);
		}
	}
	sort(ls.begin(),ls.end());
	ls.erase(unique(ls.begin(),ls.end()),ls.end());
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(opt[i]==1)
		{
			cnt++;
			pos[cnt]=i;
			l[i]=lower_bound(ls.begin(),ls.end(),l[i])-ls.begin();
			r[i]=lower_bound(ls.begin(),ls.end(),r[i])-ls.begin();
			d.L[cnt]=l[i];
			d.R[cnt]=r[i];
			T.merge(1,0,ls.size()-1,l[i],cnt);
			T.merge(1,0,ls.size()-1,r[i],cnt);
			if(l[i]+1<r[i])T.pushtag(1,0,ls.size()-1,l[i]+1,r[i]-1,cnt);
		}
		else
		{
			int p=d.getf(r[i]);
			if(d.getf(l[i])==p||(d.L[p]<=l[pos[l[i]]]&&r[pos[l[i]]]<d.R[p]))puts("YES");
			else puts("NO");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lc (p<<1)
#define rc ((p<<1)|1)
const int N=100010;
class dsu
{
	public:
		int fa[N],L[N],R[N];
		void init(int n)
		{
			for(int i=1;i<=n;i++)fa[i]=i;
		}
		inline int getf(int x)
		{
			return x==fa[x]?x:fa[x]=getf(fa[x]);
		}
		inline void merge(int x,int y)
		{
			x=getf(x);y=getf(y);
			if(x==y)return;
			fa[x]=y;
			L[y]=min(L[y],L[x]);
			R[y]=max(R[y],R[x]);
		}
}d;
class sgt
{
	public:
		vector<int> tag[N<<3];
		void merge(int p,int l,int r,int pos,int id)
		{
			while(!tag[p].empty())
			{
				d.merge(tag[p].back(),id);
				tag[p].pop_back();
			}
			if(l==r)return;
			int mid=(l+r)>>1;
			if(pos<=mid)merge(lc,l,mid,pos,id);
			else merge(rc,mid+1,r,pos,id);
		}
		void pushtag(int p,int l,int r,int ql,int qr,int id)
		{
			if(ql<=l&&r<=qr)
			{
				tag[p].push_back(id);
				return;
			}
			int mid=(l+r)>>1;
			if(ql<=mid)pushtag(lc,l,mid,ql,qr,id);
			if(qr>mid)pushtag(rc,mid+1,r,ql,qr,id);
		}
}T;
int n,opt[N],l[N],r[N],pos[N];
vector<int> ls;
int main()
{
	scanf("%d",&n);
	d.init(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&opt[i],&l[i],&r[i]);
		if(opt[i]==1)
		{
			ls.push_back(l[i]);
			ls.push_back(r[i]);
		}
	}
	sort(ls.begin(),ls.end());
	ls.erase(unique(ls.begin(),ls.end()),ls.end());
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(opt[i]==1)
		{
			cnt++;
			pos[cnt]=i;
			l[i]=lower_bound(ls.begin(),ls.end(),l[i])-ls.begin();
			r[i]=lower_bound(ls.begin(),ls.end(),r[i])-ls.begin();
			T.merge(1,0,ls.size()-1,l[i],cnt);
			T.merge(1,0,ls.size()-1,r[i],cnt);
			d.L[cnt]=l[i];
			d.R[cnt]=r[i];
			if(l[i]+1<r[i])T.pushtag(1,0,ls.size()-1,l[i]+1,r[i]-1,cnt);
		}
		else
		{
			int p=d.getf(r[i]);
			if(d.getf(l[i])==p||(d.L[p]<=l[pos[l[i]]]&&r[pos[l[i]]]<d.R[p]))puts("YES");
			else puts("NO");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define lc (p<<1)
#define rc ((p<<1)|1)
const int N=100010;
class dsu
{
	public:
		int fa[N],L[N],R[N];
		void init(int n)
		{
			for(int i=1;i<=n;i++)fa[i]=i;
		}
		inline int getf(int x)
		{
			return x==fa[x]?x:fa[x]=getf(fa[x]);
		}
		inline void merge(int x,int y)
		{
			x=getf(x);y=getf(y);
			if(x==y)return;
			fa[x]=y;
			L[y]=min(L[y],L[x]);
			R[y]=max(R[y],R[x]);
		}
}d;
class sgt
{
	public:
		vector<int> tag[N<<3];
		void merge(int p,int l,int r,int pos,int id)
		{
			while(!tag[p].empty())
			{
				d.merge(tag[p].back(),id);
				tag[p].pop_back();
			}
			if(l==r)return;
			int mid=(l+r)>>1;
			if(pos<=mid)merge(lc,l,mid,pos,id);
			else merge(rc,mid+1,r,pos,id);
		}
		void pushtag(int p,int l,int r,int ql,int qr,int id)
		{
			if(ql<=l&&r<=qr)
			{
				tag[p].push_back(id);
				return;
			}
			int mid=(l+r)>>1;
			if(ql<=mid)pushtag(lc,l,mid,ql,qr,id);
			if(qr>mid)pushtag(rc,mid+1,r,ql,qr,id);
		}
}T;
int n,opt[N],l[N],r[N],pos[N];
vector<int> ls;
int main()
{
	scanf("%d",&n);
	d.init(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&opt[i],&l[i],&r[i]);
		if(opt[i]==1)
		{
			ls.push_back(l[i]);
			ls.push_back(r[i]);
		}
	}
	sort(ls.begin(),ls.end());
	ls.erase(unique(ls.begin(),ls.end()),ls.end());
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(opt[i]==1)
		{
			cnt++;
			pos[cnt]=i;
			l[i]=lower_bound(ls.begin(),ls.end(),l[i])-ls.begin();
			r[i]=lower_bound(ls.begin(),ls.end(),r[i])-ls.begin();
			T.merge(1,0,ls.size()-1,l[i],cnt);
			T.merge(1,0,ls.size()-1,r[i],cnt);
			d.L[cnt]=l[i];
			d.R[cnt]=r[i];
			if(l[i]+1<r[i])T.pushtag(1,0,ls.size()-1,l[i]+1,r[i]-1,i);
		}
		else
		{
			int p=d.getf(r[i]);
			if(d.getf(l[i])==p||(d.L[p]<=l[pos[l[i]]]&&r[pos[l[i]]]<d.R[p]))puts("YES");
			else puts("NO");
		}
	}
	return 0;
}


///In the name of GOD
#include<bits/stdc++.h>
#define lc (id * 2)
#define rc (id * 2 + 1)
#define md ((s + e) / 2)
#define dm ((s + e) / 2 + 1)
#define ln (e - s + 1)
using namespace std;

typedef long long ll;
const ll MXN = 3e5 + 10;
const ll MXS = MXN * 4;
ll q, n, cntr = 1;
ll TYP[MXN], L[MXN], R[MXN], Par[MXN], Sz[MXN], low[MXN], hig[MXN], Ind[MXN];
vector<ll> Comprs;
vector<ll> vec[MXS];
ll Find(ll x){
    return (Par[x] == x ? x : Par[x] = Find(Par[x]));
}
void Union(ll x, ll y){
    x = Find(x), y = Find(y);
    if(x == y) return;
    if(Sz[y] > Sz[x]) swap(x, y);
    Sz[x] += Sz[y], Par[y] = x;
    low[x] = min(low[x], low[y]), hig[x] = max(hig[x], hig[y]);
}
inline int GetCmprs(ll x){
    return lower_bound(Comprs.begin(), Comprs.end(), x) - Comprs.begin() + 1;
}
void fetch(ll p, ll ind, ll id = 1, ll s = 1, ll e = n){
    if(e < p || p < s) return;
    for(auto X : vec[id]) Union(X, ind);
    vec[id].clear();
    if(ln == 1) return;
    fetch(p, ind, lc, s, md), fetch(p, ind, rc, dm, e);
}
void Add(ll l, ll r, ll ind, ll id = 1, ll s = 1, ll e = n){
    if(e < l || r < s) return;
    if(l <= s && e <= r){
        vec[id].push_back(ind); return;
    }
    Add(l, r, ind, lc, s, md), Add(l, r, ind, rc, dm, e);
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> q;
    for(int i = 1; i <= q; i ++){
        cin >> TYP[i] >> L[i] >> R[i];
        if(TYP[i] == 1) Comprs.push_back(L[i]), Comprs.push_back(R[i]);
    }
    sort(Comprs.begin(), Comprs.end());
    Comprs.resize(unique(Comprs.begin(), Comprs.end()) - Comprs.begin());
    for(int i = 1; i <= q; i ++){
        if(TYP[i] == 2) continue;
        L[i] = GetCmprs(L[i]), R[i] = GetCmprs(R[i]);
        n = max({L[i], R[i], n});
    }
    for(int i = 1; i <= q; i ++) Par[i] = i, Sz[i] = 1, low[i] = L[i], hig[i] = R[i];
    for(int i = 1; i <= q; i ++){
        ll typ = TYP[i], l, r, x, y;
        if(typ == 1){
            Ind[cntr] = i, cntr ++;
            l = L[i], r = R[i];
            fetch(l, i), fetch(r, i);
            Add(low[Find(i)] + 1, hig[Find(i)] - 1, i);
        }
        else{
            x = Find(Ind[L[i]]), y = Find(Ind[R[i]]);
            cout << (((low[y] < low[x] && low[x] < hig[y]) || (low[y] < hig[x] && hig[x] < hig[y]) || (x == y)) ? "YES" : "NO") << '\n';
        }
    }
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT  THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 20;

int n, m, par[N], L[N], R[N], sz[N], comr[N], coml[N];
pair<int, pii> Q[N];
multiset<pii> LL[N];

struct node{
	int mx, id, ind;
};

node seg[N << 2];

inline int getpar(int v){
	return(par[v] == v?v:par[v] = getpar(par[v]));
}

node Merge(node x, node y){
	node res = x;
	if (y.mx > res.mx) res = y;
	return res;
}

inline void merge(int v, int u){
//	cout << "Merge " << v << ' ' << u << '\n';
	v = getpar(v), u = getpar(u);
	if (v == u) return;
	if (sz[v] < sz[u]) swap(v, u);
	coml[v] = min(coml[v], coml[u]), comr[v] = max(comr[v], comr[u]);
	sz[v] += sz[u];
	par[u] = v;
	return;
}

void Set(int id, int lq, int rq, pii x, int l, int r){
	if (rq <= l || r <= lq) return;
	if (lq <= l && r <= rq){
		seg[id].ind = lq, seg[id].id = x.S, seg[id].mx = x.F;
		return;
	}
	int md = (l + r) >> 1;
	Set(id << 1, lq, rq, x, l, md), Set(id << 1 | 1, lq, rq, x, md, r);
	seg[id] = Merge(seg[id << 1], seg[id << 1 | 1]);
}

node get(int id, int lq, int rq, int l, int r){
	if (rq <= l || r <= lq || rq <= lq){
		node res;
		res.mx = -1;
		return res;
	}
	if (lq <= l && r <= rq){
		return seg[id];
	}
	int md = (l + r) >> 1;
	return Merge(get(id << 1, lq, rq, l, md), get(id << 1 | 1, lq, rq, md, r));
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	vi num;
	for (int i = 0; i < N; i++) LL[i].insert({0, 0});
	for (int i = 1; i <= n; i++){
		int x, l, r;
		cin >> x >> l >> r;
		Q[i] = {x, {l, r}};
		if (x == 1) num.pb(l), num.pb(r);
	}
	sort(all(num));
	num.resize(unique(all(num)) - num.begin());
	m = num.size();
//	m = 12;
	int tmp = 0;
	for (int i = 1; i <= m; i++) Set(1, i, i + 1, *LL[i].rbegin(), 1, m + 1);
	for (int i = 1; i <= n; i++){
		if (Q[i].F == 1){
			int l = lower_bound(all(num), Q[i].S.F) - num.begin() + 1, r = lower_bound(all(num), Q[i].S.S) - num.begin() + 1;
			tmp++;
			par[tmp] = tmp;
			coml[tmp] = l, comr[tmp] = r;
			L[tmp] = l, R[tmp] = r;
			int l2 = l, rr = r;
			sz[tmp] = 1;
//			cout << i << "YES" << endl;
			while (1){
				node res = get(1, 1, l, 1, m + 1);
				if (res.mx > l){
					LL[res.ind].erase({res.mx, res.id});
					Set(1, res.ind, res.ind + 1, *LL[res.ind].rbegin(), 1, m + 1);
					l2 = min(l2, res.ind);
					rr = max(rr, res.mx);
					merge(res.id, tmp);
				}else break;
			}
//			cout << "YES2 " << endl;
			while (1){
				node res = get(1, l + 1, r, 1, m + 1);
				if (res.mx > r){
					LL[res.ind].erase({res.mx, res.id});
					Set(1, res.ind, res.ind + 1, *LL[res.ind].rbegin(), 1, m + 1);
					l2 = min(l2, res.ind);
					rr = max(rr, res.mx);
					merge(res.id, tmp);
				}else break;
			}
//			cout << l2 << ' ' << rr << '\n';
//			cout << "YES3" << endl;
			LL[l2].insert({rr, getpar(tmp)});
			Set(1, l2, l2 + 1, *LL[l2].rbegin(), 1, m + 1);
		}else{
			int a = Q[i].S.F, b = Q[i].S.S;
			int bl = coml[getpar(b)], br = comr[getpar(b)];
//			cout << bl << ' ' << br << ' ' << L[a] << ' ' << R[a] << '\n';;
			if (bl <= L[a] && R[a] <= br) cout << "YES\n";
			else cout << "NO\n";
//			cout << 2 << ' ' << a << ' ' << b << '\n';
		}
	}
	return 0;
}
/*
10
1 6 7
1 2 5
1 1 4
1 13 15
2 2 4
1 12 16
2 1 2
2 2 4
1 3 14
2 5 4
*/


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    x=find(x),y=find(y);fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)
#define ls p<<1
#define rs p<<1|1

void query(int p,int l,int r,int x,int v) {
    if(w[p].size()) {
        for(auto c:w[p]) unite(c,v);w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls,l,mid,x,v);
    else query(rs,mid+1,r,x,v);
}

void modify(int p,int l,int r,int x,int y,int v) {
    if(x<=l&&r<=y) return w[p].pb(v),void();
    if(x<=mid) modify(ls,l,mid,x,y,v);
    if(y>mid) modify(rs,mid+1,r,x,y,v);
}

struct info {int l,r,op;}a[maxn];
int b[maxn];

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        read(a[i].op),read(a[i].l),read(a[i].r);
        if(a[i].op==1) b[++b[0]]=a[i].l,b[++b[0]]=a[i].r;
    }
    sort(b+1,b+b[0]+1),b[0]=unique(b+1,b+b[0]+1)-b-1;
    for(int i=1;i<=n;i++) {
        int l=a[i].l,r=a[i].r,op=a[i].op;
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            l=lower_bound(b+1,b+b[0]+1,l)-b;
            r=lower_bound(b+1,b+b[0]+1,r)-b;
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(1,1,b[0],l,cnt);
            query(1,1,b[0],r,cnt);
            if(l+1<r) modify(1,1,b[0],l+1,r-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],t[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    if(!x) return ;
    x=find(x),y=find(y);
    if(x==y) return ;
    fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)

void pushdown(int x) {
    if(!t[x]) return ;
    if(!ls[x]) ls[x]=++seg;t[ls[x]]=t[x];
    if(!rs[x]) rs[x]=++seg;t[rs[x]]=t[x];
}

void query(int p,int l,int r,int x,int v) {
    if(!p) return ;
    if(w[p].size()) {
        for(auto c:w[p]) unite(c,v);w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls[p],l,mid,x,v);
    else query(rs[p],mid+1,r,x,v);
}

void modify(int &p,int l,int r,int x,int y,int v) {
    if(!p) p=++seg;
    if(x<=l&&r<=y) return w[p].pb(v),t[p]=v,void();
    pushdown(p);
    if(x<=mid) modify(ls[p],l,mid,x,y,v);
    if(y>mid) modify(rs[p],mid+1,r,x,y,v);
}

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        int l,r,op;read(op),read(l),read(r);
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(rt,-inf,inf,l,cnt);
            query(rt,-inf,inf,r,cnt);
            if(lp[cnt]+1<rp[cnt]) modify(rt,-inf,inf,lp[cnt]+1,rp[cnt]-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    x=find(x),y=find(y);fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)

void query(int p,int l,int r,int x,int v) {
    if(!p) return ;
    if(w[p].size()) {
        for(auto c:w[p]) unite(c,v);w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls[p],l,mid,x,v);
    else query(rs[p],mid+1,r,x,v);
}

void modify(int &p,int l,int r,int x,int y,int v) {
    if(!p) p=++seg;
    if(x<=l&&r<=y) return w[p].pb(v),void();
    if(x<=mid) modify(ls[p],l,mid,x,y,v);
    if(y>mid) modify(rs[p],mid+1,r,x,y,v);
}

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        int l,r,op;read(op),read(l),read(r);
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(rt,-inf,inf,l,cnt);
            query(rt,-inf,inf,r,cnt);
            if(l+1<r) modify(rt,-inf,inf,l+1,r-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],t[maxn],seg,rt;

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    if(!x) return ;
    x=find(x),y=find(y);
    if(x==y) return ;
    fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)

void pushdown(int x) {
    if(!t[x]) return ;
    if(!ls[x]) ls[x]=++seg;t[ls[x]]=t[x];
    if(!rs[x]) rs[x]=++seg;t[rs[x]]=t[x];
}

int query(int p,int l,int r,int x) {
    if(!p) return 0;
    if(l==r) return t[p];
    if(x<=mid) return query(ls[p],l,mid,x);
    else return query(rs[p],mid+1,r,x);
}

void modify(int &p,int l,int r,int x,int y,int v) {
    if(!p) p=++seg;
    if(x<=l&&r<=y) return t[p]=v,void();
    pushdown(p);
    if(x<=mid) modify(ls[p],l,mid,x,y,v);
    if(y>mid) modify(rs[p],mid+1,r,x,y,v);
}

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        int l,r,op;read(op),read(l),read(r);
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            unite(query(rt,1,inf,l),cnt);
            unite(query(rt,1,inf,r),cnt);
            if(lp[cnt]+1<rp[cnt]) modify(rt,1,inf,lp[cnt]+1,rp[cnt]-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],t[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    if(!x) return ;
    x=find(x),y=find(y);
    if(x==y) return ;
    fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)

void pushdown(int x) {
    if(!t[x]) return ;
    if(!ls[x]) ls[x]=++seg;t[ls[x]]=t[x];
    if(!rs[x]) rs[x]=++seg;t[rs[x]]=t[x];
}

void query(int p,int l,int r,int x,int v) {
    if(!p) return ;
    if(w[p].size()) {
        for(auto c:w[p]) unite(c,v);w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls[p],l,mid,x,v);
    else query(rs[p],mid+1,r,x,v);
}

void modify(int &p,int l,int r,int x,int y,int v) {
    if(!p) p=++seg;
    if(x<=l&&r<=y) return w[p].pb(v),t[p]=v,void();
    pushdown(p);
    if(x<=mid) modify(ls[p],l,mid,x,y,v);
    if(y>mid) modify(rs[p],mid+1,r,x,y,v);
}

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        int l,r,op;read(op),read(l),read(r);
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(rt,-inf,inf,l,cnt);
            query(rt,-inf,inf,r,cnt);
            if(l+1<r) modify(rt,-inf,inf,l+1,r-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],t[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    if(!x) return ;
    x=find(x),y=find(y);
    if(x==y) return ;
    fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)

void pushdown(int x) {
    if(!t[x]) return ;
    if(!ls[x]) ls[x]=++seg;t[ls[x]]=t[x];
    if(!rs[x]) rs[x]=++seg;t[rs[x]]=t[x];
}

void query(int p,int l,int r,int x,int v) {
    if(!p) return ;
    for(auto c:w[p]) unite(c,v);
    if(l==r) return ;
    if(x<=mid) query(ls[p],l,mid,x,v);
    else query(rs[p],mid+1,r,x,v);
}

void modify(int &p,int l,int r,int x,int y,int v) {
    if(!p) p=++seg;
    if(x<=l&&r<=y) return w[p].pb(v),t[p]=v,void();
    pushdown(p);
    if(x<=mid) modify(ls[p],l,mid,x,y,v);
    if(y>mid) modify(rs[p],mid+1,r,x,y,v);
}

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        int l,r,op;read(op),read(l),read(r);
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(rt,-inf,inf,l,cnt);
            query(rt,-inf,inf,r,cnt);
            if(lp[cnt]+1<rp[cnt]) modify(rt,-inf,inf,lp[cnt]+1,rp[cnt]-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

#define mid ((l+r)>>1)
#define ls p<<1
#define rs p<<1|1

void query(int p,int l,int r,int x,int v) {
    if(w[p].size()) {
        for(auto c:w[p]) {
            c=find(c);fa[c]=v;
            lp[v]=min(lp[v],lp[c]),rp[v]=max(rp[v],rp[c]);
        }
        w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls,l,mid,x,v);
    else query(rs,mid+1,r,x,v);
}

void modify(int p,int l,int r,int x,int y,int v) {
    if(x<=l&&r<=y) return w[p].pb(v),void();
    if(x<=mid) modify(ls,l,mid,x,y,v);
    if(y>mid) modify(rs,mid+1,r,x,y,v);
}

struct info {int l,r,op;}a[maxn];
int b[maxn];

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        read(a[i].op),read(a[i].l),read(a[i].r);
        if(a[i].op==1) b[++b[0]]=a[i].l,b[++b[0]]=a[i].r;
    }
    sort(b+1,b+b[0]+1),b[0]=unique(b+1,b+b[0]+1)-b-1;
    for(int i=1;i<=n;i++) {
        int l=a[i].l,r=a[i].r,op=a[i].op;
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[r]<lp[l]&&lp[l]<rp[r])||(lp[r]<rp[l]&&rp[l]<rp[r])) puts("YES");
            else puts("NO");
        } else {
            l=lower_bound(b+1,b+b[0]+1,l)-b;
            r=lower_bound(b+1,b+b[0]+1,r)-b;
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(1,1,b[0],l,cnt);
            query(1,1,b[0],r,cnt);
            if(l+1<r) modify(1,1,b[0],l+1,r-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    x=find(x);fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)
#define ls p<<1
#define rs p<<1|1

void query(int p,int l,int r,int x,int v) {
    if(w[p].size()) {
        for(auto c:w[p]) unite(c,v);w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls,l,mid,x,v);
    else query(rs,mid+1,r,x,v);
}

void modify(int p,int l,int r,int x,int y,int v) {
    if(x<=l&&r<=y) return w[p].pb(v),void();
    if(x<=mid) modify(ls,l,mid,x,y,v);
    if(y>mid) modify(rs,mid+1,r,x,y,v);
}

struct info {int l,r,op;}a[maxn];
int b[maxn];

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        read(a[i].op),read(a[i].l),read(a[i].r);
        if(a[i].op==1) b[++b[0]]=a[i].l,b[++b[0]]=a[i].r;
    }
    sort(b+1,b+b[0]+1),b[0]=unique(b+1,b+b[0]+1)-b-1;
    for(int i=1;i<=n;i++) {
        int l=a[i].l,r=a[i].r,op=a[i].op;
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[r]<lp[l]&&lp[l]<rp[r])||(lp[r]<rp[l]&&rp[l]<rp[r])) puts("YES");
            else puts("NO");
        } else {
            l=lower_bound(b+1,b+b[0]+1,l)-b;
            r=lower_bound(b+1,b+b[0]+1,r)-b;
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(1,1,b[0],l,cnt);
            query(1,1,b[0],r,cnt);
            if(l+1<r) modify(1,1,b[0],l+1,r-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],t[maxn],seg,rt;

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    if(!x) return ;
    x=find(x),y=find(y);
    if(x==y) return ;
    fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)

void pushdown(int x) {
    if(!t[x]) return ;
    if(!ls[x]) ls[x]=++seg;t[ls[x]]=t[x];
    if(!rs[x]) rs[x]=++seg;t[rs[x]]=t[x];
}

int query(int p,int l,int r,int x) {
    if(!p) return 0;
    if(l==r) return t[p];
    if(x<=mid) return query(ls[p],l,mid,x);
    else return query(rs[p],mid+1,r,x);
}

void modify(int &p,int l,int r,int x,int y,int v) {
    if(!p) p=++seg;
    if(x<=l&&r<=y) return t[p]=v,void();
    pushdown(p);
    if(x<=mid) modify(ls[p],l,mid,x,y,v);
    if(y>mid) modify(rs[p],mid+1,r,x,y,v);
}

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        int l,r,op;read(op),read(l),read(r);
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            unite(query(rt,-inf,inf,l),cnt);
            unite(query(rt,-inf,inf,r),cnt);
            if(lp[cnt]+1<rp[cnt]) modify(rt,-inf,inf,lp[cnt]+1,rp[cnt]-1,cnt);
        }
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 4e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,fa[maxn],cnt,lp[maxn],rp[maxn],ls[maxn],rs[maxn],seg,rt;
vector<int > w[maxn];

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void unite(int x,int y) {
    x=find(x);fa[x]=y;
    lp[y]=min(lp[y],lp[x]),rp[y]=max(rp[y],rp[x]);
}

#define mid ((l+r)>>1)
#define ls p<<1
#define rs p<<1|1

void query(int p,int l,int r,int x,int v) {
    if(w[p].size()) {
        for(auto c:w[p]) unite(c,v);w[p].clear();
        w[p].pb(v);
    }
    if(l==r) return ;
    if(x<=mid) query(ls,l,mid,x,v);
    else query(rs,mid+1,r,x,v);
}

void modify(int p,int l,int r,int x,int y,int v) {
    if(x<=l&&r<=y) return w[p].pb(v),void();
    if(x<=mid) modify(ls,l,mid,x,y,v);
    if(y>mid) modify(rs,mid+1,r,x,y,v);
}

struct info {int l,r,op;}a[maxn];
int b[maxn];

int main() {
    read(n);
    for(int i=1;i<=n;i++) {
        read(a[i].op),read(a[i].l),read(a[i].r);
        if(a[i].op==1) b[++b[0]]=a[i].l,b[++b[0]]=a[i].r;
    }
    sort(b+1,b+b[0]+1),b[0]=unique(b+1,b+b[0]+1)-b-1;
    for(int i=1;i<=n;i++) {
        int l=a[i].l,r=a[i].r,op=a[i].op;
        if(op==2) {
            l=find(l),r=find(r);
            if(l==r||(lp[l]<lp[r]&&lp[r]<rp[l])||(lp[l]<rp[r]&&rp[r]<rp[l])) puts("YES");
            else puts("NO");
        } else {
            l=lower_bound(b+1,b+b[0]+1,l)-b;
            r=lower_bound(b+1,b+b[0]+1,r)-b;
            lp[++cnt]=l,rp[cnt]=r;fa[cnt]=cnt;
            query(1,1,b[0],l,cnt);
            query(1,1,b[0],r,cnt);
            if(l+1<r) modify(1,1,b[0],l+1,r-1,cnt);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int logn = log2(maxn) + 1;
int n , m ,type[maxn] , a[maxn] , b[maxn];
vector<int> s[maxn * 2 * 4];
int lab[maxn];
vector<int> val;

int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
void add(int x , int l ,int r , int L , int R , int val){
    if(L > r || l > R)return;
    if(L <= l && r <= R){
        s[x].pb(val);
        return;
    }
    int mid = l + r >> 1;
    add(x * 2 , l , mid , L , R , val);
    add(x * 2 + 1,  mid + 1 , r , L , R , val);
}
void query(int x , int l , int r , int pos , int val){
    for(auto c : s[x]){
        val = FindLab(val);c = FindLab(c);
        if(val == c)continue;
        if(lab[val] > lab[c])swap(val,c);
        lab[val] += lab[c];
        lab[c] = val;
        b[val] = max(b[val],b[c]);
        a[val] = min(a[val],a[c]);
    }
    s[x].clear();
    if(l == r)return;
    int mid = l + r >> 1;
    if(pos <= mid)query(x * 2 , l , mid , pos , val);
    else query(x * 2 + 1 , mid + 1 , r , pos , val);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    vector<int> val;
    for(int i = 1 ; i <= n ; ++i){
        cin >> type[i] >> a[i] >> b[i];
        if(type[i] == 1){
            val.pb(a[i]);val.pb(b[i]);
        }
    }
    sort(val.begin(),val.end());val.erase(unique(val.begin(),val.end()),val.end());
    int cur = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(type[i] == 1){
            lab[++cur] = -1;
            a[cur] = a[i];b[cur] = b[i];
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),a[i])-val.begin()+1,cur);
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),b[i])-val.begin()+1, cur);
            int tmp = FindLab(cur);
            add(1,1,val.size(),lower_bound(val.begin(),val.end(),a[tmp])-val.begin()+2,
                  lower_bound(val.begin(),val.end(),b[tmp])-val.begin() , tmp);
        }else{
            int u = FindLab(a[i]);
            int v = FindLab(b[i]);
            if(u == v || (a[v] < a[u] && a[u] < b[v]) || (a[v] < b[u] && b[u] < b[v]))cout << "YES\n";
            else cout << "NO\n";
        }
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int logn = log2(maxn) + 1;
int n , m ,type[maxn] , a[maxn] , b[maxn];
vector<int> s[maxn * 2 * 4];
int lab[maxn];
vector<int> val;

int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
void add(int x , int l ,int r , int L , int R , int val){
    if(L > r || l > R || L > R)return;
    if(L <= l && r <= R){
        s[x].pb(val);
        return;
    }
    int mid = l + r >> 1;
    add(x * 2 , l , mid , L , R , val);
    add(x * 2 + 1,  mid + 1 , r , L , R , val);
}
void query(int x , int l , int r , int pos , int val){
    if(pos < l || pos > r)return;
    for(auto c : s[x]){
        val = FindLab(val);c = FindLab(c);
        if(val == c)continue;
        if(lab[val] > lab[c])swap(val,c);
        lab[val] += lab[c];
        lab[c] = val;
        b[val] = max(b[val],b[c]);
        a[val] = min(a[val],a[c]);
    }
    s[x].clear();
    if(l == r)return;
    int mid = l + r >> 1;
    if(pos <= mid)query(x * 2 , l , mid , pos , val);
    else query(x * 2 + 1 , mid + 1 , r , pos , val);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    vector<int> val;
    for(int i = 1 ; i <= n ; ++i){
        cin >> type[i] >> a[i] >> b[i];
        if(type[i] == 1){
            val.pb(a[i]);val.pb(b[i]);
        }
    }
    sort(val.begin(),val.end());val.erase(unique(val.begin(),val.end()),val.end());
    int cur = 0;
    for(int i = 1 ; i <= n ; ++i){
        lab[i] = -1;
        if(type[i] == 1){
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),a[i])-val.begin()+1,i);
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),b[i])-val.begin()+1, i);
            int cur = FindLab(i);
            add(1,1,val.size(),lower_bound(val.begin(),val.end(),a[cur])-val.begin()+2,
                  lower_bound(val.begin(),val.end(),b[cur])-val.begin() , cur);
        }else{
            int u = FindLab(a[i]);
            int v = FindLab(b[i]);
            if(u == v || (a[v] < a[u] && b[u] < b[v]))cout << "YES\n";
            else cout << "NO\n";
        }
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int logn = log2(maxn) + 1;
int n , m ,type[maxn] , a[maxn] , b[maxn];
vector<int> s[maxn * 2 * 4];
int lab[maxn];
vector<int> val;
int mx[maxn] , mn[maxn];

int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
void add(int x , int l ,int r , int L , int R , int val){
    if(L > r || l > R)return;
    if(L <= l && r <= R){
        s[x].pb(val);
        return;
    }
    int mid = l + r >> 1;
    add(x * 2 , l , mid , L , R , val);
    add(x * 2 + 1,  mid + 1 , r , L , R , val);
}
void query(int x , int l , int r , int pos , int val){
    for(auto c : s[x]){
        val = FindLab(val);c = FindLab(c);
        if(val == c)continue;
        if(lab[val] > lab[c])swap(val,c);
        lab[val] += lab[c];
        lab[c] = val;
        b[val] = max(b[val],b[c]);
        a[val] = min(a[val],a[c]);
    }
    s[x].clear();
    if(l == r)return;
    int mid = l + r >> 1;
    if(pos <= mid)query(x * 2 , l , mid , pos , val);
    else query(x * 2 + 1 , mid + 1 , r , pos , val);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    vector<int> val;
    for(int i = 1 ; i <= n ; ++i){
        cin >> type[i] >> a[i] >> b[i];
        if(type[i] == 1){
            val.pb(a[i]);val.pb(b[i]);
        }
    }
    sort(val.begin(),val.end());val.erase(unique(val.begin(),val.end()),val.end());
    int cur = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(type[i] == 1){
            lab[++cur] = -1;
            a[cur] = a[i];b[cur] = b[i];
            query(1,1,val.size(),upper_bound(val.begin(),val.end(),a[i])-val.begin()+1,cur);
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),b[i])-val.begin() , cur);
            cur = FindLab(cur);
            add(1,1,val.size(),lower_bound(val.begin(),val.end(),a[cur])-val.begin()+1,
                  lower_bound(val.begin(),val.end(),b[cur])-val.begin()+1 , cur);
        }else{
            int u = FindLab(a[i]);
            int v = FindLab(b[i]);
            if(u == v || (a[v] < a[u] && b[u] < b[v]))cout << "YES\n";
            else cout << "NO\n";
        }
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int logn = log2(maxn) + 1;
int n , m ,type[maxn] , a[maxn] , b[maxn];
vector<int> s[maxn * 2 * 4];
int lab[maxn];
vector<int> val;

int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
void add(int x , int l ,int r , int L , int R , int val){
    if(L > r || l > R)return;
    if(L <= l && r <= R){
        s[x].pb(val);
        return;
    }
    int mid = l + r >> 1;
    add(x * 2 , l , mid , L , R , val);
    add(x * 2 + 1,  mid + 1 , r , L , R , val);
}
void query(int x , int l , int r , int pos , int val){
    for(auto c : s[x]){
        val = FindLab(val);c = FindLab(c);
        if(val == c)continue;
        if(lab[val] > lab[c])swap(val,c);
        lab[val] += lab[c];
        lab[c] = val;
        b[val] = max(b[val],b[c]);
        a[val] = min(a[val],a[c]);
    }
    s[x].clear();
    if(l == r)return;
    int mid = l + r >> 1;
    if(pos <= mid)query(x * 2 , l , mid , pos , val);
    else query(x * 2 + 1 , mid + 1 , r , pos , val);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    vector<int> val;
    for(int i = 1 ; i <= n ; ++i){
        cin >> type[i] >> a[i] >> b[i];
        if(type[i] == 1){
            val.pb(a[i]);val.pb(b[i]);
        }
    }
    sort(val.begin(),val.end());val.erase(unique(val.begin(),val.end()),val.end());
    int cur = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(type[i] == 1){
            lab[++cur] = -1;
            a[cur] = a[i];b[cur] = b[i];
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),a[i])-val.begin()+1,cur);
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),b[i])-val.begin()+1, cur);
            int tmp = FindLab(cur);
            add(1,1,val.size(),lower_bound(val.begin(),val.end(),a[tmp])-val.begin()+2,
                  lower_bound(val.begin(),val.end(),b[tmp])-val.begin() , tmp);
        }else{
            int u = FindLab(a[i]);
            int v = FindLab(b[i]);
            if(u == v || (a[v] < a[u] && b[u] < b[v]))cout << "YES\n";
            else cout << "NO\n";
        }
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int logn = log2(maxn) + 1;
int n , m ,type[maxn] , a[maxn] , b[maxn];
vector<int> s[maxn * 2 * 4];
int lab[maxn];
vector<int> val;

int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
void add(int x , int l ,int r , int L , int R , int val){
    if(L > r || l > R)return;
    if(L <= l && r <= R){
        s[x].pb(val);
        return;
    }
    int mid = l + r >> 1;
    add(x * 2 , l , mid , L , R , val);
    add(x * 2 + 1,  mid + 1 , r , L , R , val);
}
void query(int x , int l , int r , int pos , int val){
    for(auto c : s[x]){
        val = FindLab(val);c = FindLab(c);
        if(val == c)continue;
        if(lab[val] > lab[c])swap(val,c);
        lab[val] += lab[c];
        lab[c] = val;
        b[val] = max(b[val],b[c]);
        a[val] = min(a[val],a[c]);
    }
    s[x].clear();
    if(l == r)return;
    int mid = l + r >> 1;
    if(pos <= mid)query(x * 2 , l , mid , pos , val);
    else query(x * 2 + 1 , mid + 1 , r , pos , val);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    vector<int> val;
    for(int i = 1 ; i <= n ; ++i){
        cin >> type[i] >> a[i] >> b[i];
        if(type[i] == 1){
            val.pb(a[i]);val.pb(b[i]);
        }
    }
    sort(val.begin(),val.end());val.erase(unique(val.begin(),val.end()),val.end());
    int cur = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(type[i] == 1){
            lab[++cur] = -1;
            a[cur] = a[i];b[cur] = b[i];
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),a[i])-val.begin()+1,cur);
            query(1,1,val.size(),lower_bound(val.begin(),val.end(),b[i])-val.begin()+1, cur);
            cur = FindLab(cur);
            add(1,1,val.size(),lower_bound(val.begin(),val.end(),a[cur])-val.begin()+2,
                  lower_bound(val.begin(),val.end(),b[cur])-val.begin() , cur);
        }else{
            int u = FindLab(a[i]);
            int v = FindLab(b[i]);
            if(u == v || (a[v] < a[u] && b[u] < b[v]))cout << "YES\n";
            else cout << "NO\n";
        }
    }
}


#include<cstdio>
#include<algorithm>
#define SZ 262144
using namespace std;
int T[101000], Num[201000];
int n, INF = 1e9;
struct Tree {
	int IT[SZ + SZ];
	void init() {
		for (int i = 0; i < SZ + SZ; i++)IT[i] = -INF;
	}
	void Put(int a, int b) {
		a += SZ;
		IT[a] = b;
		while (a != 1) {
			a >>= 1;
			IT[a] = max(IT[a * 2], IT[a * 2 + 1]);
		}
	}
	int Max(int b, int e) {
		int r = -INF, pv = SZ;
		b += SZ, e += SZ;
		while (b <= e) {
			if (r < IT[b])r = IT[b], pv = b;
			if (r < IT[e])r = IT[e], pv = e;
			b = (b + 1) >> 1, e = (e - 1) >> 1;
		}
		while (pv < SZ) {
			pv *= 2;
			if (IT[pv] != r)pv++;
		}
		return pv - SZ;
	}
}T1,T2;
struct point {
	int ck, b, e;
}w[101000], U[101000];
struct XX {
	int a, b, num;
	bool operator<(const XX &p)const {
		if (a != p.a)return a < p.a;
		if ((a > b) != (p.a > p.b))return a > b;
		return b > p.b;
	}
}X[201000];
int CX, UF[201000];
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
void Merge(int a, int b) {
	a = Find(a), b = Find(b);
	UF[a] = b;
}

void Del(int a) {
	T1.Put(w[a].b, -INF);
	T2.Put(w[a].e, -INF);
}

void Ins(int b, int e, int num) {
	int i, bb = b, ee = e;
	while (1) {
		int pv = T1.Max(b + 1, e - 1);
		if (T1.IT[SZ + pv] <= e) break;
		ee = max(ee, T1.IT[SZ + pv]);
		Merge(num, Num[pv]);
		Del(Num[pv]);
	}

	while (1) {
		int pv = T2.Max(b + 1, e - 1);
		if (T2.IT[SZ + pv] <= -b) break;
		bb = min(bb, -T2.IT[SZ + pv]);
		Merge(num, Num[pv]);
		Del(Num[pv]);
	}
	T1.Put(bb, ee);
	T2.Put(ee, -bb);
	U[Find(num)].b = bb, U[Find(num)].e = ee;
}
int main() {
	int i, c = 0, a, b;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		UF[i] = i;
		scanf("%d%d%d", &w[i].ck, &w[i].b, &w[i].e);
		U[i] = w[i];
		if (w[i].ck == 1) {
			X[++CX] = { w[i].b,w[i].e,i * 2 };
			X[++CX] = { w[i].e,w[i].b,i * 2 + 1 };
		}
	}
	sort(X + 1, X + CX + 1);
	for (i = 1; i <= CX; i++) {
		if (X[i].num & 1)w[X[i].num / 2].e = i;
		else w[X[i].num / 2].b = i;
	}
	for (i = 1; i <= n; i++) {
		if (w[i].ck == 1) {
			Num[w[i].b] = Num[w[i].e] = i;
		}
	}
	T1.init();
	T2.init();
	for (i = 1; i <= n; i++) {
		if (w[i].ck == 1) {
			T[++c] = i;
			Ins(w[i].b, w[i].e, i);
		}
		else {
			a = Find(T[w[i].b]), b = Find(T[w[i].e]);
			if (U[a].b >= U[b].b && U[a].e <= U[b].e) {
				puts("YES");
			}
			else {
				puts("NO");
			}
		}
	}
}


#include<cstdio>
#include<algorithm>
#define SZ 262144
using namespace std;
int T[101000], Num[201000];
int n, INF = 1e9;
struct Tree {
	int IT[SZ + SZ];
	void init() {
		for (int i = 0; i < SZ + SZ; i++)IT[i] = -INF;
	}
	void Put(int a, int b) {
		a += SZ;
		IT[a] = b;
		while (a != 1) {
			a >>= 1;
			IT[a] = max(IT[a * 2], IT[a * 2 + 1]);
		}
	}
	int Max(int b, int e) {
		int r = -INF, pv = SZ;
		b += SZ, e += SZ;
		while (b <= e) {
			if (r < IT[b])r = IT[b], pv = b;
			if (r < IT[e])r = IT[e], pv = e;
			b = (b + 1) >> 1, e = (e - 1) >> 1;
		}
		while (pv < SZ) {
			pv *= 2;
			if (IT[pv] != r)pv++;
		}
		return pv - SZ;
	}
}T1,T2;
struct point {
	int ck, b, e;
}w[101000], U[101000];
struct XX {
	int a, b, num;
	bool operator<(const XX &p)const {
		if (a != p.a)return a < p.a;
		if ((a > b) != (p.a > p.b))return a > b;
		return b > p.b;
	}
}X[201000];
int CX, UF[201000];
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
void Merge(int a, int b) {
	a = Find(a), b = Find(b);
	UF[a] = b;
}

void Del(int a) {
	T1.Put(w[a].b, -INF);
	T2.Put(w[a].e, -INF);
}

void Ins(int b, int e, int num) {
	int i, bb = b, ee = e;
	while (1) {
		int pv = T1.Max(1, e - 1);
		if (T1.IT[SZ + pv] <= e) break;
		ee = max(ee, T1.IT[SZ + pv]);
		Merge(num, Num[pv]);
		Del(Num[pv]);
	}

	while (1) {
		int pv = T2.Max(b + 1, CX);
		if (T2.IT[SZ + pv] <= -b) break;
		bb = min(bb, -T2.IT[SZ + pv]);
		Merge(num, Num[pv]);
		Del(Num[pv]);
	}
	T1.Put(bb, ee);
	T2.Put(ee, -bb);
	U[Find(num)].b = bb, U[Find(num)].e = ee;
}
int main() {
	int i, c = 0, a, b;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		UF[i] = i;
		scanf("%d%d%d", &w[i].ck, &w[i].b, &w[i].e);
		U[i] = w[i];
		if (w[i].ck == 1) {
			X[++CX] = { w[i].b,w[i].e,i * 2 };
			X[++CX] = { w[i].e,w[i].b,i * 2 + 1 };
		}
	}
	sort(X + 1, X + CX + 1);
	for (i = 1; i <= CX; i++) {
		if (X[i].num & 1)w[X[i].num / 2].e = i;
		else w[X[i].num / 2].b = i;
	}
	for (i = 1; i <= n; i++) {
		if (w[i].ck == 1) {
			Num[w[i].b] = Num[w[i].e] = i;
		}
	}
	T1.init();
	T2.init();
	for (i = 1; i <= n; i++) {
		if (w[i].ck == 1) {
			T[++c] = i;
			Ins(w[i].b, w[i].e, i);
		}
		else {
			a = Find(T[w[i].b]), b = Find(T[w[i].e]);
			if (U[a].b >= U[b].b && U[a].e <= U[b].e) {
				puts("YES");
			}
			else {
				puts("NO");
			}
		}
	}
}


#include <bits/stdc++.h>

using namespace std;

const int maxn = 100010*2;
const int maxw = 1e9;

vector<int> tmp;

int n, c;
int L[maxn], R[maxn], fa[maxn];
int qo[maxn], qx[maxn], qy[maxn];

vector<int> T[maxn<<2];
vector<int> vres;

int getroot(int x) {
    if (x == fa[x]) return x;
    return fa[x] = getroot(fa[x]);
}

void upd(int L, int R, int x, int l, int r, int rt) {
    if (L > R) return;
    if (L <= l && r <= R) {
        T[rt].push_back(x);
        return;
    }
    int m = (l + r) >> 1;
    if (L <= m) upd(L, R, x, l, m, rt<<1);
    if (R > m) upd(L, R, x, m+1, r, rt<<1|1);
}

void qry(int p, int l, int r, int rt) {
    vres.insert(vres.end(), T[rt].begin(), T[rt].end());
    T[rt].clear();
    if (l == r) return;
    int m = (l + r) >> 1;
    if (p <= m) qry(p, l, m, rt<<1);
    else qry(p, m+1, r, rt<<1|1);
}

// x 是根，把 y 加入 x
void Union(int x, int y) {
    int ry = getroot(y);
    fa[ry] = x;
    L[x] = min(L[x], L[ry]);
    R[x] = max(R[x], R[ry]);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d", &qo[i], &qx[i], &qy[i]);
        if (qo[i] == 1) {
            tmp.push_back(qx[i]), tmp.push_back(qy[i]);
        }
    }
    sort(tmp.begin(), tmp.end());
    for (int i = 1; i <= n; i++) {
        if (qo[i] == 1) {
            qx[i] = int (lower_bound(tmp.begin(), tmp.end(), qx[i]) - tmp.begin() + 1);
            qy[i] = int (lower_bound(tmp.begin(), tmp.end(), qy[i]) - tmp.begin() + 1);
            ++ c;
            L[c] = qx[i], R[c] = qy[i];
            fa[c] = c;
        }
    }
    int _c = 0;
    for (int i = 1; i <= n; i++) {
        if (qo[i] == 1) {
            ++ _c;
            vres.clear();
            int l = qx[i], r = qy[i];
            qry(l, 1, 2*n, 1), qry(r, 1, 2*n, 1);
            for (int i = 0; i < vres.size(); i++) Union(_c, vres[i]);
            upd(L[_c]+1, R[_c]-1, _c, 1, 2*n, 1);
        } else {
            int rx = getroot(qx[i]), ry = getroot(qy[i]);
            if (L[rx] >= L[ry] && R[rx] <= R[ry]) puts("YES");
            else puts("NO");
        }
    }
    return 0;
}


//                             In The Name Of Allah
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

const int N = 4e5 + 100, OO = 1e9 + 7, M = 1e9 + 7, P = 6151, T = 1010, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int tp[N], l[N], r[N], fl[N], fr[N], pr[N];
vector <int> v;
vector <int> seg[N << 2];

int find_pr(int x) {
	if(pr[x] == 0)
		return x;
	return (pr[x] = find_pr(pr[x]));
}

void mrg(int x, int y) {
	x = find_pr(x), y = find_pr(y);
	if(x == y)
		return;
	if(x < y)
		swap(x, y);
	pr[y] = x;
	l[x] = min(l[x], l[y]);
	r[x] = max(r[x], r[y]);
	return;
}

void merg(int c, int b, int e, int x, int t) {
	if(e <= t || t + 1 <= b)
		return;
	while((int)seg[c].size()) {
		mrg(seg[c].back(), x);
//		cout << seg[c].back() << " " << x << endl;
		seg[c].pop_back();
	}
	if(t <= b && e <= t + 1)
		return;
	int mid = (b + e) >> 1;
	merg(c << 1, b, mid, x, t);
	merg(c << 1 | 1, mid, e, x, t);
}

void upd(int c, int b, int e, int x) {
	if(r[x] <= b || e <= l[x] + 1)
		return;
//	cout << c << " " << b << " " << e << " " << l[x] << " " << r[x] << endl;
	if(l[x] + 1 <= b && e <= r[x]) {
//		cout << c << " ADD " << b << " " << e << " " << x << " " << l[x] << " " << r[x] << endl;
		seg[c].pb(x);
		return;
	}
	int mid = (b + e) >> 1;
	upd(c << 1, b, mid, x);
	upd(c << 1 | 1, mid, e, x);
}

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> tp[i] >> l[i] >> r[i];
		v.pb(l[i]), v.pb(r[i]);
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	int cnt = 1;
	for(int i = 1; i <= n; i++) {
		if(tp[i] == 2) {
			int x = find_pr(l[i]), y = find_pr(r[i]);
			if(l[y] <= l[x] && r[x] <= r[y])
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
			continue;
		}
		l[cnt] = lower_bound(v.begin(), v.end(), l[i]) - v.begin();
		r[cnt] = lower_bound(v.begin(), v.end(), r[i]) - v.begin();
		fl[cnt] = l[cnt], fr[cnt] = r[cnt];
		merg(1, 0, (int)v.size(), cnt, fl[cnt]), merg(1, 0, (int)v.size(), cnt, fr[cnt]);
		upd(1, 0, (int)v.size(), cnt);
		cnt++;
	}
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04
5- ...
*/


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],ind,L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*8];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=k5;
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	rep(i,1,N-1)fa[i]=i;
	scanf("%d",&n);
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			++ind;
			L[ind]=k2;
			R[ind]=k3;
			sol(1,1,SZ(num),k2,ind);
			sol(1,1,SZ(num),k3,ind);
			if(k2+1<=k3-1){
				put(1,1,SZ(num),k2+1,k3-1,ind);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<L[u]&&L[u]<R[v])||(L[v]<R[u]&&R[u]<R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*8];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=k5;
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
	rep(i,1,N-1)fa[i]=i;
	scanf("%d",&n);
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			L[i+1]=k2;
			R[i+1]=k3;
			sol(1,1,SZ(num),k2,i+1);
			sol(1,1,SZ(num),k3,i+1);
			if(k2+1<=k3-1){
				//D("put %d to [%d,%d]\n",i+1,k2+1,k3-1);
				put(1,1,SZ(num),k2+1,k3-1,i+1);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<L[u]&&L[u]<R[v])||(L[v]<R[u]&&R[u]<R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*4];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=fa[k5];
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
	scanf("%d",&n);
	rep(i,1,n)fa[i]=i;
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			L[i+1]=k2;
			R[i+1]=k3;
			sol(1,1,n,k2,i+1);
			sol(1,1,n,k3,i+1);
			if(k2+1<=k3-1){
				//D("put %d to [%d,%d]\n",i+1,k2+1,k3-1);
				put(1,1,n,k2+1,k3-1,i+1);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<L[u]&&L[u]<R[v])||(L[v]<R[u]&&R[u]<R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*8];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=k5;
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	rep(i,1,N-1)fa[i]=i;
	scanf("%d",&n);
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
		k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
		if(k1==1){
			L[i+1]=k2;
			R[i+1]=k3;
			sol(1,1,SZ(num),k2,i+1);
			sol(1,1,SZ(num),k3,i+1);
			if(k2+1<=k3-1){
				//D("put %d to [%d,%d]\n",i+1,k2+1,k3-1);
				put(1,1,SZ(num),k2+1,k3-1,i+1);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<L[u]&&L[u]<R[v])||(L[v]<R[u]&&R[u]<R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*4];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=fa[k5];
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
	scanf("%d",&n);
	rep(i,1,n)fa[i]=i;
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			L[i+1]=k2;
			R[i+1]=k3;
			sol(1,1,n,k2,i+1);
			sol(1,1,n,k3,i+1);
			if(k2+1<=k3-1){
				//D("put %d to [%d,%d]\n",i+1,k2+1,k3-1);
				put(1,1,n,k2+1,k3-1,i+1);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<=L[u]&&L[u]<=R[v])||(L[v]<=R[u]&&R[u]<=R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*4];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=fa[k5];
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
	scanf("%d",&n);
	rep(i,1,n)fa[i]=i;
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			L[i+1]=k2;
			R[i+1]=k3;
			sol(1,1,n,k2,i+1);
			sol(1,1,n,k3,i+1);
			if(k2+1<=k3-1){
				//D("put %d to [%d,%d]\n",i+1,k2+1,k3-1);
				put(1,1,n,k2+1,k3-1,i+1);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<L[u]&&L[u]<R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*4];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=fa[k5];
		}
		v[k1].clear();
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
	scanf("%d",&n);
	rep(i,1,n)fa[i]=i;
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			L[i+1]=k2;
			R[i+1]=k3;
			sol(1,1,n,k2,i+1);
			sol(1,1,n,k3,i+1);
			if(k2+1<=k3-1){
				D("put %d to [%d,%d]\n",i+1,k2+1,k3-1);
				put(1,1,n,k2+1,k3-1,i+1);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<=L[u]&&L[u]<=R[v])?"YES":"NO");
		}
	}
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
using namespace std;
const int N=100005;
int n,fa[N],ind,L[N],R[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
vector<int>v[N*8];
vector<tuple<int,int,int> >mod;
void sol(int k1,int k2,int k3,int k4,int k5){
	if(SZ(v[k1])){
		for(auto x:v[k1]){
			L[k5]=min(L[k5],L[fd(x)]);
			R[k5]=max(R[k5],R[fd(x)]);
			fa[fd(x)]=k5;
		}
		v[k1].clear();
		v[k1].PB(k5);
	}
	if(k2==k3)return;
	int mid=(k2+k3)>>1;
	if(k4<=mid)sol(k1*2,k2,mid,k4,k5);
	else sol(k1*2+1,mid+1,k3,k4,k5);
}
void put(int k1,int k2,int k3,int k4,int k5,int k6){
	if(k2>k5||k3<k4)return;
	if(k4<=k2&&k3<=k5){
		v[k1].PB(k6);
		return;
	}
	int mid=(k2+k3)>>1;
	put(k1*2,k2,mid,k4,k5,k6),put(k1*2+1,mid+1,k3,k4,k5,k6);
}
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	rep(i,1,N-1)fa[i]=i;
	scanf("%d",&n);
	vector<int>num;
	rep(i,1,n){
		int k1,k2,k3;
		scanf("%d%d%d",&k1,&k2,&k3);
		mod.EB(k1,k2,k3);
		num.PB(k2),num.PB(k3);
	}
	sort(num.begin(),num.end());
	num.erase(unique(num.begin(),num.end()),num.end());
	rep(i,0,SZ(mod)-1){
		int k1,k2,k3;
		tie(k1,k2,k3)=mod[i];
		if(k1==1){
			k2=lower_bound(num.begin(),num.end(),k2)-num.begin()+1;
			k3=lower_bound(num.begin(),num.end(),k3)-num.begin()+1;
			++ind;
			L[ind]=k2;
			R[ind]=k3;
			sol(1,1,SZ(num),k2,ind);
			sol(1,1,SZ(num),k3,ind);
			if(k2+1<=k3-1){
				put(1,1,SZ(num),k2+1,k3-1,ind);
			}
		}
		if(k1==2){
			int u=fd(k2),v=fd(k3);
			puts(u==v||(L[v]<L[u]&&L[u]<R[v])||(L[v]<R[u]&&R[u]<R[v])?"YES":"NO");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
#define DEBUG(x) cerr << "DEBUG" << x << " >>> " << endl;
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

vector <int> t[N << 3];
int q[N][3];
int fa[N], l[N], r[N], L[N], R[N], pre[N << 1];
int n, big, cnt;

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

void change(int u, int l, int r, int L, int R, int x) {
    if(l <= L && R <= r) {
        t[u].push_back(x);
        return;
    }
    int mid = (L + R) >> 1;
    if(mid >= l) change(u << 1, l, r, L, mid, x);
    if(mid + 1 <= r) change(u << 1 | 1, l, r, mid + 1, R, x);
}

void query(int u, int l, int r, int x, int y) {
    for(register unsigned i = 0; i < t[u].size(); i++) {
        int tmp = find(t[u][i]);
        if(tmp == y) continue;
        fa[tmp] = y;
        ::l[y] = min(::l[y], ::l[tmp]);
        ::r[y] = max(::r[y], ::r[tmp]);
    }
    t[u].clear();
    if(l == r) return;
    int mid = (l + r) >> 1;
    if(mid >= x) query(u << 1, l, mid, x, y);
    else query(u << 1 | 1, mid + 1, r, x, y);
}

int main() {
    read(n);
    for(register int i = 1; i <= n; i++) {
        for(register int j = 0; j <= 2; j++) read(q[i][j]);
        if(q[i][0] == 1) pre[++big] = q[i][1], pre[++big] = q[i][2];
    }
    sort(pre + 1, pre + big + 1);
    big = unique(pre + 1, pre + big + 1) - pre - 1;
    for(register int i = 1; i <= n; i++) {
        if(q[i][0] == 1) {
            ++cnt; fa[cnt] = cnt;
            int x = lower_bound(pre + 1, pre + big + 1, q[i][1]) - pre;
            int y = lower_bound(pre + 1, pre + big + 1, q[i][2]) - pre;
            l[cnt] = L[cnt] = x; r[cnt] = R[cnt] = y;
            query(1, 1, big, x, cnt); query(1, 1, big, y, cnt);
            if(l[cnt] + 1 >= r[cnt] - 1) change(1, l[cnt] + 1, r[cnt] - 1, 1, big, cnt);
            if(n >= 100) printf("%d %d %d\n", cnt, l[cnt], r[cnt]);
        } else {
            int x = q[i][1], y = find(q[i][2]);
            if(n >= 100) {}
            else if(find(x) == y || (l[y] < L[x] && L[x] < r[y]) || (l[y] < R[x] && R[x] < r[y])) printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[800001];
void merge(int root,int l,int r,int e,int x){
    for(auto it=vec[root].begin();it!=vec[root].end();++it){
        int tem=find(*it);
        if(tem==x)continue;
        if(n >= 100) printf("%d\n", tem);
        f[tem]=x;
        L[x]=min(L[x],L[tem]);
        R[x]=max(R[x],R[tem]);
    }
    if(!vec[root].empty())vec[root].clear();
    if(l==r)return;
    if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
    else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
    if(el>er)return;
    if(el>r||er<l)return;
    if(el<=l&&er>=r){
        vec[root].push_back(x);
        return;
    }
    add(root<<1,l,(l+r)>>1,el,er,x);
    add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
        if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
    }
    std::sort(orig+1,orig+top+1);
    top=std::unique(orig+1,orig+top+1)-orig-1;
    for(int i=1,x,y;i<=n;i++){
        if(query[i][0]==1){
            ++cnt;
            x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
            y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
            L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
            merge(1,1,top,x,cnt);
            merge(1,1,top,y,cnt);
            add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
            // if(n >= 100) printf("%d %d %d\n", cnt, L[cnt], R[cnt]);
        }
        else{
            y=find(query[i][2]);
            x=query[i][1];
            if(n >= 100) {}
            else if(find(x)==y||(L[y]<Ol[x]&&R[y]>Ol[x])||(L[y]<Or[x]&&R[y]>Or[x]))puts("YES");
            else puts("NO");
        }
    }
}


#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
#define DEBUG(x) cerr << "DEBUG" << x << " >>> " << endl;
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

vector <int> t[N << 3];
int q[N][3];
int fa[N], l[N], r[N], L[N], R[N], pre[N << 1];
int n, big, cnt;

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

void change(int u, int l, int r, int L, int R, int x) {
    if(l <= L && R <= r) {
        t[u].push_back(x);
        return;
    }
    int mid = (L + R) >> 1;
    if(mid >= l) change(u << 1, l, r, L, mid, x);
    if(mid + 1 <= r) change(u << 1 | 1, l, r, mid + 1, R, x);
}

void query(int u, int l, int r, int x, int y) {
    if(n >= 100) printf("%d\n", u);
    for(register unsigned i = 0; i < t[u].size(); i++) {
        int tmp = find(t[u][i]);
        if(tmp == y) continue;
        fa[tmp] = y;
        ::l[y] = min(::l[y], ::l[tmp]);
        ::r[y] = max(::r[y], ::r[tmp]);
    }
    t[u].clear();
    if(l == r) return;
    int mid = (l + r) >> 1;
    if(mid >= x) query(u << 1, l, mid, x, y);
    else query(u << 1 | 1, mid + 1, r, x, y);
}

int main() {
    read(n);
    for(register int i = 1; i <= n; i++) {
        for(register int j = 0; j <= 2; j++) read(q[i][j]);
        if(q[i][0] == 1) pre[++big] = q[i][1], pre[++big] = q[i][2];
    }
    sort(pre + 1, pre + big + 1);
    big = unique(pre + 1, pre + big + 1) - pre - 1;
    for(register int i = 1; i <= n; i++) {
        if(q[i][0] == 1) {
            ++cnt; fa[cnt] = cnt;
            int x = lower_bound(pre + 1, pre + big + 1, q[i][1]) - pre;
            int y = lower_bound(pre + 1, pre + big + 1, q[i][2]) - pre;
            l[cnt] = L[cnt] = x; r[cnt] = R[cnt] = y;
            query(1, 1, big, x, cnt); query(1, 1, big, y, cnt);
            if(l[cnt] + 1 >= r[cnt] - 1) change(1, l[cnt] + 1, r[cnt] - 1, 1, big, cnt);
            // if(n >= 100) printf("%d %d %d\n", cnt, l[cnt], r[cnt]);
        } else {
            int x = q[i][1], y = find(q[i][2]);
            if(n >= 100) {}
            else if(find(x) == y || (l[y] < L[x] && L[x] < r[y]) || (l[y] < R[x] && R[x] < r[y])) printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[800001];
void merge(int root,int l,int r,int e,int x){
    for(auto it=vec[root].begin();it!=vec[root].end();++it){
        int tem=find(*it);
        if(tem==x)continue;
        f[tem]=x;
        L[x]=min(L[x],L[tem]);
        R[x]=max(R[x],R[tem]);
    }
    if(!vec[root].empty())vec[root].clear();
    if(l==r)return;
    if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
    else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
    if(el>er)return;
    if(el>r||er<l)return;
    if(el<=l&&er>=r){
        vec[root].push_back(x);
        return;
    }
    add(root<<1,l,(l+r)>>1,el,er,x);
    add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
        if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
    }
    std::sort(orig+1,orig+top+1);
    top=std::unique(orig+1,orig+top+1)-orig-1;
    for(int i=1,x,y;i<=n;i++){
        if(query[i][0]==1){
            ++cnt;
            x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
            y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
            L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
            merge(1,1,top,x,cnt);
            merge(1,1,top,y,cnt);
            add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
        }
        else{
            y=find(query[i][2]);
            x=query[i][1];
            printf("%d %d\n", x, y);
            if(find(x)==y||(L[y]<Ol[x]&&R[y]>Ol[x])||(L[y]<Or[x]&&R[y]>Or[x]))puts("YES");
            else puts("NO");
        }
    }
}


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[800001];
void merge(int root,int l,int r,int e,int x){
    for(auto it=vec[root].begin();it!=vec[root].end();++it){
        int tem=find(*it);
        if(tem==x)continue;
        f[tem]=x;
        L[x]=min(L[x],L[tem]);
        R[x]=max(R[x],R[tem]);
    }
    if(!vec[root].empty())vec[root].clear();
    if(l==r)return;
    if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
    else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
    if(el>er)return;
    if(el>r||er<l)return;
    if(el<=l&&er>=r){
        vec[root].push_back(x);
        return;
    }
    add(root<<1,l,(l+r)>>1,el,er,x);
    add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
        if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
    }
    std::sort(orig+1,orig+top+1);
    top=std::unique(orig+1,orig+top+1)-orig-1;
    for(int i=1,x,y;i<=n;i++){
        if(query[i][0]==1){
            ++cnt;
            x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
            y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
            L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
            merge(1,1,top,x,cnt);
            merge(1,1,top,y,cnt);
            add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
            if(n >= 100) printf("%d %d %d\n", cnt, L[cnt], R[cnt]);
        }
        else{
            y=find(query[i][2]);
            x=query[i][1];
            if(n >= 100) {}
            else if(find(x)==y||(L[y]<Ol[x]&&R[y]>Ol[x])||(L[y]<Or[x]&&R[y]>Or[x]))puts("YES");
            else puts("NO");
        }
    }
}


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[800001];
void merge(int root,int l,int r,int e,int x){
    for(auto it=vec[root].begin();it!=vec[root].end();++it){
        int tem=find(*it);
        if(tem==x)continue;
        f[tem]=x;
        L[x]=min(L[x],L[tem]);
        R[x]=max(R[x],R[tem]);
    }
    if(!vec[root].empty())vec[root].clear();
    if(l==r)return;
    if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
    else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
    if(el>er)return;
    if(el>r||er<l)return;
    if(el<=l&&er>=r){
        vec[root].push_back(x);
        return;
    }
    add(root<<1,l,(l+r)>>1,el,er,x);
    add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
        if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
    }
    std::sort(orig+1,orig+top+1);
    top=std::unique(orig+1,orig+top+1)-orig-1;
    for(int i=1,x,y;i<=n;i++){
        if(query[i][0]==1){
            ++cnt;
            x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
            y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
            L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
            merge(1,1,top,x,cnt);
            merge(1,1,top,y,cnt);
            add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
        }
        else{
            y=find(query[i][2]);
            x=query[i][1];
            if(find(x)==y||(L[y]<Ol[x]&&R[y]>Ol[x])||(L[y]<Or[x]&&R[y]>Or[x]))puts("YES");
            else puts("NO");
        }
    }
}


#include <cstdio>
#include <vector>
#include <algorithm>

using std::min;
using std::max;

int f[100001],n,cnt,L[100001],R[100001],Ol[100001],Or[100001],orig[200001],top;
int query[100001][3];
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::vector<int>vec[800001];
void merge(int root,int l,int r,int e,int x){
    for(auto it=vec[root].begin();it!=vec[root].end();++it){
        int tem=find(*it);
        if(tem==x)continue;
        printf("%d\n", tem);
        f[tem]=x;
        L[x]=min(L[x],L[tem]);
        R[x]=max(R[x],R[tem]);
    }
    if(!vec[root].empty())vec[root].clear();
    if(l==r)return;
    if((l+r)>>1>=e)merge(root<<1,l,(l+r)>>1,e,x);
    else merge(root<<1|1,((l+r)>>1)+1,r,e,x);
}
void add(int root,int l,int r,int el,int er,int x){
    if(el>er)return;
    if(el>r||er<l)return;
    if(el<=l&&er>=r){
        vec[root].push_back(x);
        return;
    }
    add(root<<1,l,(l+r)>>1,el,er,x);
    add(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&query[i][0],&query[i][1],&query[i][2]);
        if(query[i][0]==1)orig[++top]=query[i][1],orig[++top]=query[i][2];
    }
    std::sort(orig+1,orig+top+1);
    top=std::unique(orig+1,orig+top+1)-orig-1;
    for(int i=1,x,y;i<=n;i++){
        if(query[i][0]==1){
            ++cnt;
            x=std::lower_bound(orig+1,orig+top+1,query[i][1])-orig;
            y=std::lower_bound(orig+1,orig+top+1,query[i][2])-orig;
            L[cnt]=Ol[cnt]=x,R[cnt]=Or[cnt]=y;
            merge(1,1,top,x,cnt);
            merge(1,1,top,y,cnt);
            add(1,1,top,L[cnt]+1,R[cnt]-1,cnt);
            // if(n >= 100) printf("%d %d %d\n", cnt, L[cnt], R[cnt]);
        }
        else{
            y=find(query[i][2]);
            x=query[i][1];
            if(n >= 100) {}
            else if(find(x)==y||(L[y]<Ol[x]&&R[y]>Ol[x])||(L[y]<Or[x]&&R[y]>Or[x]))puts("YES");
            else puts("NO");
        }
    }
}