#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define dbg(x) { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 105;

vector<int> g[N];
pii temp[N];
int vis[N];

bool ck (pii x, pii y) {
    int a = x.fi, b = x.se, c = y.fi, d = y.se;
    if ((c < a && a < d) || (c < b && b < d)) return 1;
    return 0;
}

int ans;

void dfs (int a, int b) {
    if (a==b) ans = 1;
    vis[a] = 1;
    for (auto i: g[a]) {
        if(!vis[i])
            dfs(i,b);
    }
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    IOS;

    int t;
    cin >> t;
    int c = 1;
    for (int i = 1; i <= t; i++) {
        int n, x, y;
        cin >> n >> x >> y;
        if (n==1) {temp[c] = {x,y}; c++;}
        else {
            ans = 0;
            for (int j = 0; j < N; j++)
            {
                vis[j] = 0;
                g[j].clear();
            }
            for (int j = 1; j <= c; j++) {
                for (int k = 1; k <= c; k++) {
                    if (ck(temp[j],temp[k])) g[j].pb(k);
                }
            }
            dfs(x,y);
            if (ans) cout << "YES\n";
            else cout << "NO\n";
        }
    }
    return 0;
}


/*
			copyright
	# all rights reserved #
			# 2019 #
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <utility>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
typedef long long ll;
using namespace std;
const long long INF = 1ll << 32;
int q, n;
vector<int> pa;
vector <pair<int, int>> v;
int find(int i) {
	if (pa[i] == i)
		return i;
	return pa[i] = find(pa[i]);
}
void add(int a ,int b) {
	for (int i = 0; i < n; i++) {
		int c = v[i].first;
		int d = v[i].second;
		if ((c < a&&a < d) || (c < b&&b < d)) {
			int u = find(pa[i]);
			int b = find(pa[n]);
			pa[u] = b;
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d", &q);
	pa.resize(101);
	for (int i = 0; i < 101 ; i++)
		pa[i] = i;
	while (q--) {
		int type,a,b;
		scanf("%d", &type);
		scanf("%d %d", &a, &b);
		if (type == 1) {
			add(a,b);
			v.push_back({ a,b });
			n++;
		}
		else {
			a--; b--;
			if (find(pa[a]) == find(pa[b]))
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}


/*
			copyright
	# all rights reserved #
			# 2019 #
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <utility>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const long long INF = 1ll << 32;

int n;
bool vis[101];
vector <pair<int, int>>v;
void dfs(int idx) {
	vis[idx-1] = 1;
	for (int i = 0; i < v.size(); i++) {
		if (vis[i])
			continue;
		if (v[i].first < v[idx - 1].first&&v[idx - 1].first < v[i].second)
			dfs(i + 1);
		else if (v[i].first < v[idx - 1].second&&v[idx - 1].second < v[i].second)
			dfs(i + 1);
	}
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d", &n);
	while (n--) {
		int ty, a, b;
		scanf("%d %d %d", &ty, &a, &b);
		if (ty == 1)
			v.push_back({ a,b });
		else {
			for (int i = 0; i < 101; i++)
				vis[i] = 0;
			dfs(a);
			if (vis[b])
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
	return 0;
}


/*
			copyright
	# all rights reserved #
			# 2019 #
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <utility>
#include <string>
#include <string.h>
#include <math.h>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
typedef long long ll;
using namespace std;
const long long INF = 1ll << 32;
const double pi = acos(-1);

int n;
vector <vector <int>> g;
vector <pair<int, int>> v;
inline void add(int a,int b) {
	g.push_back(vector <int>());
	int si = v.size();
	v.push_back({ a, b });
	for (int i = 0; i < si; i++) {
		int f = v[i].first, s = v[i].second;
		if ((a < f&&f < b) || (a < s&&s < b))
			g[i].push_back(si);
		if ((f < a&&a < s) || (f < b&&b < s))
			g[si].push_back(i);
		//c/out << g[0].size()<<"   "<<g[1].size() << endl;
	}
	return;
}
inline bool check(int a, int b) {
	vector <bool> vis(v.size(), 0);
	queue<int> q;
	q.push(a);
	vis[a] = 1;
	while (!q.empty()) {
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++) {
			int ch = g[fr][i];
			//cout << ch << endl;
			if (ch == b)
				return 1;
			if (!vis[ch]) {
				vis[ch] = 1;
				q.push(ch);
			}
		}
	}
	return 0;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d", &n);
	while (n--) {
		int type, a, b;
		scanf("%d %d %d", &type, &a, &b);
		if (type == 1)
			add(a,b);
		else {
			a--; b--;
			if (check(a, b))
				puts("YES");
			else
				puts("NO");
		}
	}
	return 0;
}


/*
			copyright
	# all rights reserved #
			# 2019 #
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <utility>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const long long INF = 1ll << 32;

int n,k,i=-1;
vector <int>a, b;
bool vis[101];
void dfs(int i) {
	vis[i] = 1;
	for (int k = 0; k < n; k++) {
		if (vis[k + 1])
			continue;
		if (a[i-1] > a[k] && a[i-1] < b[k])
			dfs(k + 1);
		else if (b[i-1] > a[k] && b[i-1] < b[k])
			dfs(k+1);
	}
	return;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d", &k);
	for (int j = 0; j < k; j++) {
		int t;
		scanf("%d", &t);
		if (t == 1) {
			n++;
			i++;
			a.resize(n);
			b.resize(n);
			scanf("%d %d", &a[i], &b[i]);
		}
		else {
			memset(vis, 0, n);
			int x, y;
			scanf("%d %d", &x, &y);
			dfs(x);
			if (vis[y])
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}

	return 0;
}


/*
			copyright
	# all rights reserved #
			# 2019 #
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <utility>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const long long INF = 1ll << 32;

int n;
map<int, vector<int>>mp;
bool ans(int a,int b) {
	queue<int> qe;
	qe.push(a);
	while (qe.size()){
		int d = qe.front();
		qe.pop();
		for (int j = 0; j < mp[d].size(); j++) {
			if (mp[d][j] == b)
				return 1;
			qe.push(mp[d][j]);
		}
	}
	return 0;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d", &n);
	vector <pair<int, int>>v;
	while (n--) {
		int ty, a, b;
		scanf("%d %d %d", &ty, &a, &b);
		if (ty == 1) {
			v.push_back({ a,b });
			for (int i = 0; i < v.size()-1; i++) {
				if ((v[i].first < a&&a < v[i].second) || (v[i].first < b&&b < v[i].second))
					mp[v.size()-1].push_back(i);
				if ((a < v[i].first&&v[i].first < b) || (a < v[i].second&&v[i].second < b))
					mp[i].push_back(v.size() - 1);
			}
		}
		else {
			a--; b--;

			if (ans(a, b))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
pair <ll,ll> a[107];
bool vis [107];
ll cnt=0;
bool ans=0;
void dfs(ll b, ll c){
vis[b]=1;
fr(i,1,cnt+1){
if(vis[i]){
        continue;
}
if((a[i].fi<a[b].fi && a[b].fi<a[i].se) || (a[i].fi<a[b].se && a[b].se<a[i].se)){
    //cout<<i<<endl;
 if((a[c].fi<a[i].fi && a[i].fi<a[c].se) || (a[c].fi<a[i].se && a[i].se<a[c].se)){
     yes;
     ans=1;
     return;
}
    dfs(i,c);
}
}
}
void solve(){
ll u,b,c;
ll n;
cin>>n;
fr(i,0,n){
cin>>u>>b>>c;
if(u==1){
        cnt++;
    a[cnt]=mp(b,c);
}
else{   ans=0;
        memset(vis,0,sizeof(vis));
    dfs(b,c);
    if(!ans){no;}
    //cout<<a[b].fi<<" "<<a[b].se<<endl;
}
}
}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
pair <ll,ll> a[107];
bool vis [107];
ll cnt=0;
bool dfs(ll b, ll c){
vis[b]=1;
fr(i,1,cnt+1){
if(vis[i]){
        continue;
}
if((a[i].fi<a[b].fi && a[b].fi<a[i].se) || (a[i].fi<a[b].se && a[b].se<a[i].se)){
    //cout<<i<<endl;
 if((a[c].fi<a[i].fi && a[i].fi<a[c].se) || (a[c].fi<a[i].se && a[i].se<a[c].se)|| i==c){
     //cout<<i<<endl;
        return 1;
}
    dfs(i,c);
}
}
return 0;
}
void solve(){
ll u,b,c;
ll n;
cin>>n;
fr(i,0,n){
cin>>u>>b>>c;
if(u==1){
        cnt++;
    a[cnt]=mp(b,c);
}
else{
        memset(vis,0,sizeof(vis));
    dfs(b,c)?yes:no;
    //cout<<a[b].fi<<" "<<a[b].se<<endl;
}
}
}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
pair <ll,ll> a[107];
bool vis [107];
ll cnt=0;
bool dfs(ll b, ll c){
vis[b]=1;
fr(i,1,cnt+1){
if(vis[i]){
        continue;
}
if((a[i].fi<a[b].fi && a[b].fi<a[i].se) || (a[i].fi<a[b].se && a[b].se<a[i].se)){
    //cout<<i<<endl;
 if((a[c].fi<a[i].fi && a[i].fi<a[c].se) || (a[c].fi<a[i].se && a[i].se<a[c].se)|| i==c){
     //cout<<i<<endl;
        return 1;
}
    return dfs(i,c);
}
}
return 0;
}
void solve(){
ll u,b,c;
ll n;
cin>>n;
fr(i,0,n){
cin>>u>>b>>c;
if(u==1){
        cnt++;
    a[cnt]=mp(b,c);
}
else{
        memset(vis,0,sizeof(vis));
    dfs(b,c)?yes:no;
    //cout<<a[b].fi<<" "<<a[b].se<<endl;
}
}
}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
pair <ll,ll> a[107];
bool vis [107];
ll cnt=0;
void dfs(ll b, ll c){
vis[b]=1;
fr(i,1,cnt+1){
if(vis[i]){
        continue;
}
if((a[i].fi<a[b].fi && a[b].fi<a[i].se) || (a[i].fi<a[b].se && a[b].se<a[i].se)){
    dfs(i,c);
}
}
}
void solve(){
ll u,b,c;
ll n;
cin>>n;
fr(i,0,n){
cin>>u>>b>>c;
if(u==1){
        cnt++;
    a[cnt]=mp(b,c);
}
else{
        memset(vis,0,sizeof(vis));
    dfs(b,c);
    vis[c]?yes:no;
    //cout<<a[b].fi<<" "<<a[b].se<<endl;
}
}
}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
pair <ll,ll> a[107];
bool vis [107];
ll cnt=0;
bool dfs(ll b, ll c){
vis[b]=1;
fr(i,1,cnt+1){
if(vis[i]) continue;
if(a[i].fi<a[b].fi && a[b].fi<a[i].se || a[i].fi<a[b].se && a[b].se<a[i].se){
 if(a[i].fi<a[c].fi && a[c].fi<a[i].se || a[i].fi<a[c].se && a[c].se<a[i].se){
        return 1;
}
    dfs(i,c);
}
}
return 0;
}
void solve(){
ll u,b,c;
ll n;
cin>>n;
fr(i,0,n){
cin>>u>>b>>c;
if(u==1){
        cnt++;
    a[cnt]=mp(b,c);
}
else{
    dfs(b,c)?yes:no;
}
}
}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
pair <ll,ll> a[107];
bool vis [107];
ll cnt=0;
bool dfs(ll b, ll c){
vis[b]=1;
fr(i,1,cnt+1){
if(vis[i]){
        continue;
}
if((a[i].fi<a[b].fi && a[b].fi<a[i].se) || (a[i].fi<a[b].se && a[b].se<a[i].se)){
    //cout<<i<<endl;
 if((a[c].fi<a[i].fi && a[i].fi<a[c].se) || (a[c].fi<a[i].se && a[i].se<a[c].se)){
     //cout<<i<<endl;
        return 1;
}
    return dfs(i,c);
}
}
return 0;
}
void solve(){
ll u,b,c;
ll n;
cin>>n;
fr(i,0,n){
cin>>u>>b>>c;
if(u==1){
        cnt++;
    a[cnt]=mp(b,c);
}
else{
        memset(vis,0,sizeof(vis));
    dfs(b,c)?yes:no;
    //cout<<a[b].fi<<" "<<a[b].se<<endl;
}
}
}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            cin >> a;
            cin >> b;

            Inter cur;
            cur.a = a;
            cur.b = b;
            cur.index = count;

            vector<int> newAdjList;

            for(Inter prev : inters) {
                if(cur.path_to(prev))
                    newAdjList.push_back(prev.index);
                if(prev.path_to(cur))
                    prev.adjList.push_back(cur.index);
            }

            inters.push_back(cur);
            cur.adjList = newAdjList;
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()];

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            cin >> a;
            cin >> b;

            Inter cur;
            cur.a = a;
            cur.b = b;
            cur.index = count;

            vector<int> newAdjList;

            for(Inter prev : inters) {
                if(cur.path_to(prev))
                    newAdjList.push_back(prev.index);
                if(prev.path_to(cur))
                    prev.adjList.push_back(cur.index);
            }

            inters.push_back(cur);
            cur.adjList = newAdjList;
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev))
                    cur->adjList.push_back(prev.index);
                if(prev.path_to(*cur))
                    prev.adjList.push_back(cur->index);
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev))
                    cur->adjList.push_back(prev.index);
                if(prev.path_to(*cur))
                    prev.adjList.push_back(cur->index);
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Iter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            cin >> a;
            cin >> b;

            Inter cur;
            cur.a = a;
            cur.b = b;
            cur.index = count;

            vector<int> newAdjList;

            for(Inter prev : inters) {
                if(cur.path_to(prev))
                    newAdjList.push_back(prev.index);
                if(prev.path_to(cur))
                    prev.adjList.push_back(cur.index);
            }

            inters.push_back(cur);
            cur.adjList = newAdjList;
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()];

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur_ptr = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev))
                    cur->adjList.push_back(prev.index);
                if(prev.path_to(*cur))
                    prev.adjList.push_back(cur->index);
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev)) {
                    cur->adjList.push_back(prev.index);
                    cout << "New Edge: " << cur->index << " to " << prev.index << endl;
                }
                if(prev.path_to(*cur)) {
                    prev.adjList.push_back(cur->index);
                    cout << "New Edge: " << prev.index << " to " << cur->index << endl;
                }
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                cout << "cur = " << cur << endl;
                cout << "visited = " << visited[cur] << endl;

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev)) {
                    cur->adjList.push_back(prev.index);
                    cout << "New Edge: " << cur->index << " to " << prev.index << endl;
                }
                if(prev.path_to(*cur)) {
                    prev.adjList.push_back(cur->index);
                    cout << "New Edge: " << prev.index << " to " << cur->index << endl;
                }
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                cout << "cur = " << cur << endl;
                cout << "visited = " << visited[cur] << endl;
                cout << "adj list size = " << inters[cur].adjList.size() << endl;

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev)) {
                    cur->adjList.push_back(prev.index);
                    cout << "New Edge: " << cur->index << " to " << prev.index << endl;
                }
                if(prev.path_to(*cur)) {
                    prev.adjList.push_back(cur->index);
                    cout << "New Edge: " << prev.index << " to " << cur->index << endl;
                }
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                cout << "cur = " << cur << endl;

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            cin >> a;
            cin >> b;

            Inter cur;
            cur.a = a;
            cur.b = b;
            cur.index = count;

            vector<int> newAdjList;

            for(Inter prev : inters) {
                if(cur.path_to(prev))
                    newAdjList.push_back(prev.index);
                if(prev.path_to(cur))
                    prev.adjList.push_back(cur.index);
            }

            inters.push_back(cur);
            cur.adjList = newAdjList;
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()];

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Iter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            cin >> a;
            cin >> b;

            Inter cur;
            cur.a = a;
            cur.b = b;
            cur.index = count;

            vector<int> newAdjList;

            for(Inter prev : inters) {
                if(cur.path_to(prev))
                    newAdjList.push_back(prev.index);
                if(prev.path_to(cur))
                    prev.adjList.push_back(cur.index);
            }

            inters.push_back(cur);
            cur.adjList = newAdjList;
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()];

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : cur.adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(auto prev = inters.begin(); prev != inters.end(); ++prev) {
                if(cur->path_to(*prev)) {
                    cur->adjList.push_back(prev->index);
                    cout << "New Edge: " << cur->index << " to " << prev->index << endl;
                }
                if(prev->path_to(*cur)) {
                    prev->adjList.push_back(cur->index);
                    cout << "New Edge: " << prev->index << " to " << cur->index << endl;
                }
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                cout << "cur = " << cur << endl;
                cout << "visited = " << visited[cur] << endl;
                cout << "adj list size = " << inters[cur].adjList.size() << endl;

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(auto prev = inters.begin(); prev != inters.end(); ++prev) {
                if(cur->path_to(*prev)) {
                    cur->adjList.push_back(prev->index);
                    //cout << "New Edge: " << cur->index << " to " << prev->index << endl;
                }
                if(prev->path_to(*cur)) {
                    prev->adjList.push_back(cur->index);
                    //cout << "New Edge: " << prev->index << " to " << cur->index << endl;
                }
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                //cout << "cur = " << cur << endl;
                //cout << "visited = " << visited[cur] << endl;
                //cout << "adj list size = " << inters[cur].adjList.size() << endl;

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Iter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            cin >> a;
            cin >> b;

            Inter cur;
            cur.a = a;
            cur.b = b;
            cur.index = count;

            vector<int> newAdjList;

            for(Inter prev : inters) {
                if(cur.path_to(prev))
                    newAdjList.push_back(prev.index);
                if(prev.path_to(cur))
                    prev.adjList.push_back(cur.index);
            }

            inters.push_back(cur);
            cur.adjList = newAdjList;
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()];

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : cur.adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <vector>
#include <iostream>
#include <stack>
using namespace std;

struct Inter {
    int a;
    int b;
    int index;
    vector<int> adjList;

    bool path_to(Inter i) {
        return (a > i.a && a < i.b) || (b > i.a && b < i.b);
    }
};

vector<Inter> inters;

int main() {
    int N;
    cin >> N;
    int count = 0;

    for(int i = 0; i < N; i++) {
        int start, a, b;

        cin >> start;

        if(start == 1) {
            Inter* cur = new Inter();

            cin >> cur->a;
            cin >> cur->b;
            cur->index = count;

            for(Inter prev : inters) {
                if(cur->path_to(prev)) {
                    cur->adjList.push_back(prev.index);
                    cout << "New Edge: " << cur->index << " to " << prev.index << endl;
                }
                if(prev.path_to(*cur)) {
                    prev.adjList.push_back(cur->index);
                    cout << "New Edge: " << prev.index << " to " << cur->index << endl;
                }
            }

            inters.push_back(*cur);
            count++;
        }

        else {
            cin >> a;
            cin >> b;

            a--;
            b--;

            bool visited[inters.size()] = {false};

            bool found = false;
            stack<int> s;
            s.push(a);

            while(!s.empty()) {
                int cur = s.top();
                s.pop();

                if(cur == b)
                {
                    found = true;
                    break;
                }

                if(visited[cur]) continue;
                else visited[cur] = true;

                for(int next : inters[cur].adjList) {
                    s.push(next);
                }
            }

            if(found) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
        }

    }

}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int visited[105];

map<long long,vector<long long> > m;
map<ll,pair<ll,ll> > intervals;
map<ll,int> interv;

void dfs(ll x){
	long long i;
	visited[x]=1;
	for(i=0;i<m[x].size();i++){
		if (visited[m[x][i]]==0) dfs(m[x][i]);
	}
}

int main()
{
    ll n,i,j,x,a,b;
    cin >> n;
    int cpt=0;
    for(i=1;i<=n;i++){
        cin >> x >> a >> b;
        if (x==1){
            cpt++;
            intervals[cpt]=make_pair(a,b);
            interv[cpt]=1;
            for(j=1;j<cpt;j++){
                if (interv[j]==1){
                    if (a<intervals[j].second && a>intervals[j].first){
                        m[cpt].push_back(j);
                    }
                    else if (b<intervals[j].second && b>intervals[j].first){
                        m[cpt].push_back(j);
                    }
                    if (intervals[j].second<b && intervals[j].second>a){
                        m[j].push_back(cpt);
                    }
                    else if (intervals[j].first<b && intervals[j].first>a){
                        m[j].push_back(cpt);
                    }
                }
            }
        }

        else {
            memset(visited,0,sizeof visited);
            dfs(a);
            if (visited[b]==1) cout << "YES\n";
            else cout << "NO\n";
        }

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int visited[105];

map<long long,vector<long long> > m;
map<ll,pair<ll,ll> > intervals;
map<ll,int> interv;

void dfs(ll x){
	long long i;
	visited[x]=1;
	for(i=0;i<m[x].size();i++){
		if (visited[m[x][i]]==0) dfs(m[x][i]);
	}
}

int main()
{
    ll n,i,j,x,a,b;
    cin >> n;
    int cpt=0;
    for(i=1;i<=n;i++){
        cin >> x >> a >> b;
        if (x==1){
            cpt++;
            intervals[cpt]=make_pair(a,b);
            interv[cpt]=1;
            for(j=1;j<cpt;j++){
                if (interv[j]==1){
                    if (a<intervals[j].second && a>intervals[j].first){
                        m[cpt].push_back(j);
                    }
                    else if (b<intervals[j].second && b>intervals[j].first){
                        m[cpt].push_back(j);
                    }
                    else if (intervals[j].second<b && intervals[j].second>a){
                        m[j].push_back(cpt);
                    }
                    else if (intervals[j].first<b && intervals[j].first>a){
                        m[j].push_back(cpt);
                    }
                }
            }
        }

        else {
            memset(visited,0,sizeof visited);
            dfs(a);
            if (visited[b]==1) cout << "YES\n";
            else cout << "NO\n";
        }

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int visited[105];

map<long long,vector<long long> > m;
map<ll,pair<ll,ll> > intervals;
map<ll,int> interv;

void dfs(ll x){
	long long i;
	visited[x]=1;
	for(i=0;i<m[x].size();i++){
		if (visited[m[x][i]]==0) dfs(m[x][i]);
	}
}

int main()
{
    ll n,i,j,x,a,b;
    cin >> n;
    int cpt=0;
    for(i=1;i<=n;i++){
        cin >> x >> a >> b;
        if (x==1){
            cpt++;
            intervals[cpt]=make_pair(a,b);
            interv[cpt]=1;
            for(j=1;j<cpt;j++){
                if (interv[j]==1){
                    if (a<intervals[j].second && a>intervals[j].first){
                        m[cpt].push_back(j);
                        m[j].push_back(cpt);
                    }
                    else if (b<intervals[j].second && b>intervals[j].first){
                        m[cpt].push_back(j);
                        m[j].push_back(cpt);
                    }
                    else if (intervals[j].second<b && intervals[j].second>a){
                        m[cpt].push_back(j);
                        m[j].push_back(cpt);
                    }
                    else if (intervals[j].first<b && intervals[j].first>a){
                        m[cpt].push_back(j);
                        m[j].push_back(cpt);
                    }
                }
            }
        }

        else {
            memset(visited,0,sizeof visited);
            dfs(a);
            if (visited[b]==1) cout << "YES\n";
            else cout << "NO\n";
        }

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int visited[105]={0};

map<long long,vector<long long> > m;
map<ll,pair<ll,ll> > intervals;
map<ll,int> interv;

void dfs(ll x){
	long long i;
	visited[x]=1;
	for(i=0;i<m[x].size();i++){
		if (visited[m[x][i]]==0) dfs(m[x][i]);
	}
}

int main()
{
    ll n,i,j,x,a,b;
    cin >> n;
    int cpt=0;
    for(i=1;i<=n;i++){
        cin >> x >> a >> b;
        if (x==1){
            cpt++;
            intervals[cpt]=make_pair(a,b);
            interv[cpt]=1;
            for(j=1;j<cpt;j++){
                if (interv[j]==1){
                    if (a<intervals[j].second && a>intervals[j].first){
                        m[cpt].push_back(j);
                        m[j].push_back(cpt);
                    }
                    else if (b<intervals[j].second && b>intervals[j].first){
                        m[cpt].push_back(j);
                        m[j].push_back(cpt);
                    }
                }
            }
        }
        else {
            memset(visited,0,sizeof visited);
            dfs(a);
            if (visited[b]==1) cout << "YES\n";
            else cout << "NO\n";
        }
    }
    return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

typedef std::pair<int, std::pair<int, int> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool bfs(IntervalGraph &g, int a, int b) {
  std::queue< Interval > q;
  int n = g.size();
  Visited v(n);

  q.push(g[a]);

  while(!q.empty()) {
    auto next = q.front();
    q.pop();

    if(next.first == b) return true;

    auto interval = next.second;

    for(auto nb: g) {
      auto nbInterval = nb.second;
      if (v[nb.first]) continue;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        v[nb.first] = true;
        q.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type, a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {a, b}});
        break;
      case 2:
        bfs(intervals, a, b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <stack>
using namespace std;

typedef std::pair<int, std::pair<int, int> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool dfs(IntervalGraph &g, int a, int b) {
  std::stack< Interval > s;
  int n = g.size();
  Visited v(n);

  s.push(g[a]);

  while(!s.empty()) {
    auto next = s.top();
    s.pop();

    if(next.first == b) return true;
    if(v[next.first]) continue;

    auto interval = next.second;

    for(auto nb: g) {
      auto nbInterval = nb.second;
      if (v[nb.first]) continue;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        s.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type, a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {a, b}});
        break;
      case 2:
        dfs(intervals, a, b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

typedef std::pair<int, std::pair<int, int> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool bfs(IntervalGraph &g, int a, int b) {
  std::queue< Interval > q;
  int n = g.size();
  Visited v(n);

  q.push(g[a]);
  v[a] = true;

  while(!q.empty()) {
    auto next = q.front();
    q.pop();

    if(next.first == b) return true;

    auto interval = next.second;

    for(auto nb: g) {
      if (v[nb.first]) continue;
      auto nbInterval = nb.second;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        v[nb.first] = true;
        q.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type, a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {a, b}});
        break;
      case 2:
        bfs(intervals, a, b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

typedef std::pair<int, std::pair<long, long> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool bfs(IntervalGraph &g, int a, int b) {
  std::queue< Interval > q;
  int n = g.size();
  Visited v(n);

  q.push(g[a]);
  v[a] = true;

  while(!q.empty()) {
    auto next = q.front();
    q.pop();

    if(next.first == b) return true;

    auto interval = next.second;

    for(auto nb: g) {
      if (v[nb.first]) continue;
      auto nbInterval = nb.second;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        v[nb.first] = true;
        q.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type;
    long a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {a, b}});
        break;
      case 2:
        bfs(intervals, a, b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

typedef std::pair<int, std::pair<long, long> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool bfs(IntervalGraph &g, int a, int b) {
  std::queue< Interval > q;
  int n = g.size();
  Visited v(n);

  q.push(g[a]);
  v[a] = true;

  while(!q.empty()) {
    auto next = q.front();
    q.pop();

    if(next.first == b) return true;

    auto interval = next.second;

    for(auto nb: g) {
      if (v[nb.first]) continue;
      auto nbInterval = nb.second;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        v[nb.first] = true;
        q.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type;
    long a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {--a, --b}});
        break;
      case 2:
        bfs(intervals, --a, --b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

typedef std::pair<int, std::pair<int, int> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool bfs(IntervalGraph &g, int a, int b) {
  std::queue< Interval > q;
  int n = g.size();
  Visited v(n);

  q.push(g[a]);

  while(!q.empty()) {
    auto next = q.front();
    q.pop();

    if(next.first == b) return true;
    if(v[next.first]) continue;

    auto interval = next.second;

    for(auto nb: g) {
      auto nbInterval = nb.second;
      if (v[nb.first]) continue;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        if(next.first == b) return true;
        q.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type, a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {a, b}});
        break;
      case 2:
        bfs(intervals, a, b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <stack>
using namespace std;

typedef std::pair<int, std::pair<int, int> > Interval;
typedef std::vector< Interval > IntervalGraph;
typedef std::vector< bool > Visited;

bool dfs(IntervalGraph &g, int a, int b) {
  std::stack< Interval > s;
  int n = g.size();
  Visited v(n);

  s.push(g[a]);

  while(!s.empty()) {
    auto next = s.top();
    s.pop();

    if(next.first == b) return true;
    if(v[next.first]) continue;

    auto interval = next.second;

    for(auto nb: g) {
      auto nbInterval = nb.second;
      if (v[nb.first]) continue;
      if ((nbInterval.first < interval.first && interval.first < nbInterval.second) ||
          (nbInterval.first < interval.second && interval.second < nbInterval.second)) {
        if(next.first == b) return true;
        s.push({nb.first, nbInterval});
      }
    }
  }

  return false;
}

int main () {
  int n;
  cin >> n;

  IntervalGraph intervals;

  for(int i = 0, x = 0; i < n; i++) {
    int type, a, b;
    cin >> type >> a >> b;
    switch (type) {
      case 1:
        intervals.push_back({x++, {a, b}});
        break;
      case 2:
        dfs(intervals, a, b) ? printf("YES\n") : printf("NO\n");
        break;
      default:
        break;
    }
  }
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fl(i,a,n) for(ll i=a;i<n;i++)
#define rl(i,a,n) for(ll i=a;i>=n;i--)
#define fc(i,a) for(auto& i: a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b/gcd(a,b))
#define ld double
#define ll long long
#define VLL vector<ll>
#define VVLL vector<vector<ll>>
#define mp make_pair
#define ff first
#define ss second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(a) a.size()

double tick(){
    static clock_t oldt,newt=clock();
    double diff=1.0* (newt-oldt)/CLOCKS_PER_SEC;
    oldt=newt;
    return diff;
}

ll mod(ll n,ll m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}

ll power(ll a,ll n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return a*a;
    if(n&1){
        n--;
        return a*power(power(a,2),n/2);
    }
    else return power(power(a,2),n/2);
}

VLL isPrime(1000001,true),prime,spf(1000001);
void sieve(ll n){
    isPrime[0]=isPrime[1]=false;
    for(ll i=2;i<n;i++){
        if(isPrime[i]){
            prime.pb(i);
            spf[i]=i;
        }
        for(ll j=0;j<prime.size()&&i*prime[j]<n&&prime[j]<=spf[i];j++){
            isPrime[i*prime[j]]=false;
            spf[i*prime[j]]=prime[j];
        }
    }
}

VVLL path(101);
bool dfs(ll a,ll b){
	bool visited[101]={0};
	queue<ll>move;
	move.push(a);
	while(!move.empty()){
		ll x=move.front();
		move.pop();
		visited[x]=1;
		if(x==b){
			return true;
		}
		fc(i,path[x]){
			if(!visited[i]){
				move.push(i);
				visited[i]=1;
			}
		}
		// visited[x]=0;
	}
	return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll t=1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        VVLL arr(n+1,VLL(2));
        ll index=1;
        while(n--){
        	ll q;
        	cin>>q;
        	if(q==1){
        		ll x,y;
        		cin>>x>>y;
        		arr[index][0]=x,arr[index][1]=y;
        		fl(i,1,index){
        			ll a=arr[i][0],b=arr[i][1];
        			if((a<x && x<b)||(a<y && y<b)||(x<a && a<y)||(x<b && b<y)){
        				path[index].pb(i);
        				path[i].pb(index);
					}
        		}
        		// cout<<index<<": ";
        		// fc(i,path[index]){
        		// 	cout<<i<<' ';
        		// }
        		// cout<<endl;
        		index++;
        	}
        	else{
        		ll a,b;
        		cin>>a>>b;
        		if(dfs(a,b)) cout<<"YES\n";
        		else cout<<"NO\n";
        	}
        }

    }
    cerr<<"\nExecution time: "<<tick()*1000<<" ms"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fl(i,a,n) for(ll i=a;i<n;i++)
#define rl(i,a,n) for(ll i=a;i>=n;i--)
#define fc(i,a) for(auto& i: a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b/gcd(a,b))
#define ld double
#define ll long long
#define VLL vector<ll>
#define VVLL vector<vector<ll>>
#define mp make_pair
#define ff first
#define ss second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(a) a.size()

double tick(){
    static clock_t oldt,newt=clock();
    double diff=1.0* (newt-oldt)/CLOCKS_PER_SEC;
    oldt=newt;
    return diff;
}

ll mod(ll n,ll m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}

ll power(ll a,ll n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return a*a;
    if(n&1){
        n--;
        return a*power(power(a,2),n/2);
    }
    else return power(power(a,2),n/2);
}

VLL isPrime(1000001,true),prime,spf(1000001);
void sieve(ll n){
    isPrime[0]=isPrime[1]=false;
    for(ll i=2;i<n;i++){
        if(isPrime[i]){
            prime.pb(i);
            spf[i]=i;
        }
        for(ll j=0;j<prime.size()&&i*prime[j]<n&&prime[j]<=spf[i];j++){
            isPrime[i*prime[j]]=false;
            spf[i*prime[j]]=prime[j];
        }
    }
}

VVLL path(101);
bool dfs(ll a,ll b){
	bool visited[101]={0};
	queue<ll>move;
	move.push(a);
	while(!move.empty()){
		ll x=move.front();
		move.pop();
		visited[x]=1;
		if(x==b){
			return true;
		}
		fc(i,path[x]){
			if(!visited[i]){
				move.push(i);
				visited[i]=1;
			}
		}
		// visited[x]=0;
	}
	return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll t=1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        VVLL arr(n+1,VLL(2));
        ll index=1;
        while(n--){
        	ll q;
        	cin>>q;
        	if(q==1){
        		ll x,y;
        		cin>>x>>y;
        		arr[index][0]=x,arr[index][1]=y;
        		fl(i,1,index){
        			ll a=arr[i][0],b=arr[i][1];
        			if((a<x && x<b)||(a<y && y<b)){
        				path[index].pb(i);
					}
					else if((x<a && a<y)||(x<b && b<y))
        				path[i].pb(index);
        		}
        		// cout<<index<<": ";
        		// fc(i,path[index]){
        		// 	cout<<i<<' ';
        		// }
        		// cout<<endl;
        		index++;
        	}
        	else{
        		ll a,b;
        		cin>>a>>b;
        		if(dfs(a,b)) cout<<"YES\n";
        		else cout<<"NO\n";
        	}
        }

    }
    cerr<<"\nExecution time: "<<tick()*1000<<" ms"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fl(i,a,n) for(ll i=a;i<n;i++)
#define rl(i,a,n) for(ll i=a;i>=n;i--)
#define fc(i,a) for(auto& i: a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b/gcd(a,b))
#define ld double
#define ll long long
#define VLL vector<ll>
#define VVLL vector<vector<ll>>
#define mp make_pair
#define ff first
#define ss second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(a) a.size()

double tick(){
    static clock_t oldt,newt=clock();
    double diff=1.0* (newt-oldt)/CLOCKS_PER_SEC;
    oldt=newt;
    return diff;
}

ll mod(ll n,ll m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}

ll power(ll a,ll n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return a*a;
    if(n&1){
        n--;
        return a*power(power(a,2),n/2);
    }
    else return power(power(a,2),n/2);
}

VLL isPrime(1000001,true),prime,spf(1000001);
void sieve(ll n){
    isPrime[0]=isPrime[1]=false;
    for(ll i=2;i<n;i++){
        if(isPrime[i]){
            prime.pb(i);
            spf[i]=i;
        }
        for(ll j=0;j<prime.size()&&i*prime[j]<n&&prime[j]<=spf[i];j++){
            isPrime[i*prime[j]]=false;
            spf[i*prime[j]]=prime[j];
        }
    }
}

VVLL path(101);
bool dfs(ll a,ll b){
	bool visited[101]={0};
	queue<ll>move;
	move.push(a);
	while(!move.empty()){
		ll x=move.front();
		move.pop();
		visited[x]=1;
		if(x==b){
			return true;
		}
		fc(i,path[x]){
			if(!visited[i]){
				move.push(i);
				// visited[i]=1;
			}
		}
		visited[x]=0;
	}
	return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll t=1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        VVLL arr(n+1,VLL(2));
        ll index=1;
        while(n--){
        	ll q;
        	cin>>q;
        	if(q==1){
        		ll x,y;
        		cin>>x>>y;
        		arr[index][0]=x,arr[index][1]=y;
        		fl(i,1,index){
        			ll a=arr[i][0],b=arr[i][1];
        			if((a<x && x<b)||(a<y && y<b)||(x<a && a<y)||(x<b && b<y)){
        				path[index].pb(i);
        				path[i].pb(index);
					}
        		}
        		index++;
        	}
        	else{
        		ll a,b;
        		cin>>a>>b;
        		if(dfs(a,b)) cout<<"YES\n";
        		else cout<<"NO\n";
        	}
        }

    }
    cerr<<"\nExecution time: "<<tick()*1000<<" ms"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fl(i,a,n) for(ll i=a;i<n;i++)
#define rl(i,a,n) for(ll i=a;i>=n;i--)
#define fc(i,a) for(auto& i: a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b/gcd(a,b))
#define ld double
#define ll long long
#define VLL vector<ll>
#define VVLL vector<vector<ll>>
#define mp make_pair
#define ff first
#define ss second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(a) a.size()

double tick(){
    static clock_t oldt,newt=clock();
    double diff=1.0* (newt-oldt)/CLOCKS_PER_SEC;
    oldt=newt;
    return diff;
}

ll mod(ll n,ll m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}

ll power(ll a,ll n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return a*a;
    if(n&1){
        n--;
        return a*power(power(a,2),n/2);
    }
    else return power(power(a,2),n/2);
}

VLL isPrime(1000001,true),prime,spf(1000001);
void sieve(ll n){
    isPrime[0]=isPrime[1]=false;
    for(ll i=2;i<n;i++){
        if(isPrime[i]){
            prime.pb(i);
            spf[i]=i;
        }
        for(ll j=0;j<prime.size()&&i*prime[j]<n&&prime[j]<=spf[i];j++){
            isPrime[i*prime[j]]=false;
            spf[i*prime[j]]=prime[j];
        }
    }
}

VVLL path(101);
bool dfs(ll a,ll b){
	bool visited[101]={0};
	queue<ll>move;
	move.push(a);
	while(!move.empty()){
		ll x=move.front();
		move.pop();
		visited[x]=1;
		if(x==b){
			return true;
		}
		fc(i,path[x]){
			if(!visited[i]){
				move.push(i);
				visited[i]=1;
			}
		}
		// visited[x]=0;
	}
	return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll t=1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        VVLL arr(n+1,VLL(2));
        ll index=1;
        while(n--){
        	ll q;
        	cin>>q;
        	if(q==1){
        		ll x,y;
        		cin>>x>>y;
        		arr[index][0]=x,arr[index][1]=y;
        		fl(i,1,index){
        			ll a=arr[i][0],b=arr[i][1];
        			if((a<x && x<b)||(a<y && y<b)){
        				path[index].pb(i);
					}
					if((x<a && a<y)||(x<b && b<y))
        				path[i].pb(index);
        		}
        		// cout<<index<<": ";
        		// fc(i,path[index]){
        		// 	cout<<i<<' ';
        		// }
        		// cout<<endl;
        		index++;
        	}
        	else{
        		ll a,b;
        		cin>>a>>b;
        		if(dfs(a,b)) cout<<"YES\n";
        		else cout<<"NO\n";
        	}
        }

    }
    cerr<<"\nExecution time: "<<tick()*1000<<" ms"<<endl;
    return 0;
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

struct dat
{
    int l,r,val,id;
};

int sz;

vi ad[200];

int main()
{
    int i,j,k,l,m,n,t,r;

    cin >> n ;

    dat ar[n+10];

    for(i=0; i<n; i++)
    {
        cin >> t ;

        if(t == 1)
        {
            cin >> ar[sz].l >> ar[sz].r;

            if(sz)
            {
                for(j=0; j<sz; j++)
                {
                    if(ar[sz].l >= ar[j].r || ar[sz].r <= ar[j].l)continue;
                    ad[j].pb(sz);
                    ad[sz].pb(j);
                }
            }
            sz++;
        }
        else
        {
            cin >> l >> r;

            l--,r--;

            bool ok = false;

            queue<int>q;

            q.push(l);

            int vis[sz+10];

            memset(vis,0,sizeof vis);

            int u;

            while(!q.empty())
            {
                u = q.front();
                q.pop();
               // cout << u << endl;
                if(u == r)
                {
                    ok = true;

                    break;
                }
                if(vis[u])continue;

                vis[u] = 1;

                for(auto x : ad[u])
                {
                    if(!vis[x])q.push(x);
                }
            }

            if(ok)cout << "YES" << endl;
            else cout << "NO" << endl;
        }
    }
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

struct dat
{
    int l,r,val,id;
};

int sz;

int main()
{
    int i,j,k,l,m,n,t,r;

    cin >> n ;

   dat ar[n+10];

    for(i=0;i<n;i++)
    {
        cin >> t ;

        if(t == 1)
        {
            cin >> ar[sz].l >> ar[sz].r;
            ar[sz].id = sz;
            sz++;
        }
        else
        {

             cin >> l >> r;

             l--,r--;
            sort(ar,ar+sz,[](dat &p1 , dat &p2){return p1.l<p2.l;});
            int st;
            bool ok = false;
            for(j=0;j<sz;j++)
            {
                if(ar[j].id == l)
                {
                    st = j;
                    break;
                }
            }

            //cout << st << endl;

            for(j=st-1;j>=0;j--)
            {
                if((ar[j].l < ar[j+1].l && ar[j+1].l < ar[j].r) || (ar[j].l < ar[j+1].r && ar[j+1].r < ar[j].r))
                {
                    if(j==r)
                    {
                        ok= true;
                        break;
                    }
                    continue;
                }
                break;
            }
            for(j=st+1;j<sz;j++)
            {
                if((ar[j].l < ar[j-1].l && ar[j-1].l < ar[j].r) || (ar[j].l < ar[j-1].r && ar[j-1].r < ar[j].r))
                {
                    if(j==r)
                    {
                        ok= true;
                        break;
                    }
                    continue;
                }
                break;
            }

            if(ok)cout << "YES" << endl;
            else cout << "NO" << endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
set <int> v[N],s;
bool vis[N];
queue <int> q;
void solve(int x)
{
    q.push(x);
    s.erase(x);
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        if(vis[t]) continue;
        vis[t]=1;
        for(set<int> :: iterator it=s.begin();it!=s.end();it++)
        {
            int u=*it;
            if(v[t].find(u)==v[t].end())
            {
                q.push(u);
                s.erase(u);
            }
        }
    }
}
int main()
{
    int n,m;
    read(n),read(m);
    for(re int i=1;i<=n;i++) s.insert(i);
    for(re int i=1;i<=m;i++)
    {
        int a,b;
        read(a),read(b);
        v[a].insert(b);
        v[b].insert(a);
    }
    int ans=0;
    for(re int i=1;i<=n;i++)
    {
        if(!vis[i])
            solve(i),ans++;
    }
    printf("%d",ans-1);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,m,nxt[N],pre[N],q[N],l=1,r,ans,st[N],tp;bool vis[N];
vector<int>v[N];
void erase(int x){nxt[pre[x]]=nxt[x];pre[nxt[x]]=pre[x];}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1,x,y;i<=m;i++)scanf("%d%d",&x,&y),v[x].push_back(y),v[y].push_back(x);
    for(int i=1;i<=n;i++)nxt[i]=i+1,pre[i]=i-1;nxt[0]=1;pre[n+1]=n;
    while(nxt[0]<=n){
        q[++r]=nxt[0];erase(nxt[0]);ans++;
        while(l<=r){
            int x=q[l++];
            for(int i=0;i<v[x].size();i++)vis[st[++tp]=v[x][i]]=1;
            for(int i=nxt[0];i<=n;i=nxt[i])if(!vis[i])q[++r]=i,erase(i);
            while(tp)vis[st[tp--]]=0;
        }
    }
    printf("%d\n",ans-1);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,m,nxt[N],pre[N],q[N],l=1,r,ans,st[N],tp,s[N];bool vis[N];
vector<int>v[N];
void erase(int x){nxt[pre[x]]=nxt[x];pre[nxt[x]]=pre[x];}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1,x,y;i<=m;i++)scanf("%d%d",&x,&y),v[x].push_back(y),v[y].push_back(x);
    for(int i=1;i<=n;i++)nxt[i]=i+1,pre[i]=i-1;nxt[0]=1;pre[n+1]=n;
    while(nxt[0]<=n){
        q[++r]=nxt[0];erase(nxt[0]);ans++;
        while(l<=r){
            int x=q[l++];s[ans]++;
            for(int i=0;i<v[x].size();i++)vis[st[++tp]=v[x][i]]=1;
            for(int i=nxt[0];i<=n;i=nxt[i])if(!vis[i])q[++r]=i,erase(i);
            while(tp)vis[st[tp--]]=0;
        }
    }
    printf("%d\n",ans);
    sort(s+1,s+ans+1);
    for(int i=1;i<=ans;i++)printf("%d ",s[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,m,f[N],sz[N],hd,que[N],tp,ans;
set<pair<int,int> >s;
set<int>st;
set<int>::iterator it;
vector<int>v[N];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)f[i]=i,sz[i]=1,st.insert(i),v[i].push_back(i);
    for(int i=1,x,y;i<=m;i++){
        scanf("%d%d",&x,&y);
        if(x>y)swap(x,y);s.insert(make_pair(x,y));
    }
    for(int i=1;i<=n;i++){
        int x=find(i);
        for(it=st.begin();it!=st.end();it++){
            int y=*it;if(y==find(i))continue;
            for(int k=0;k<v[y].size();k++){
                int z=v[y][k],xx=i,yy=z;
                if(xx>yy)swap(xx,yy);
                if(s.find(make_pair(xx,yy))==s.end()){
                    int xxx=find(i),yyy=y;
                    if(sz[xxx]>sz[yyy])swap(xxx,yyy);
                    ans++;f[xxx]=yyy;sz[yyy]+=sz[xxx];
                    que[++tp]=xxx;
                    for(int l=0;l<v[xxx].size();l++)v[yyy].push_back(v[xxx][l]);v[yyy].clear();
                    break;
                }
            }
        }
        while(tp)st.erase(que[tp--]);
    }
    printf("%d\n",n-1-ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,m,f[N],sz[N],hd,que[N],tp,ans;
set<pair<int,int> >s;
set<int>st;
set<int>::iterator it;
vector<int>v[N];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)f[i]=i,sz[i]=1,st.insert(i),v[i].push_back(i);
    for(int i=1,x,y;i<=m;i++){
        scanf("%d%d",&x,&y);
        if(x>y)swap(x,y);s.insert(make_pair(x,y));
    }
    for(int i=1;i<=n;i++){
        for(it=st.begin();it!=st.end();it++){
            int y=*it;if(y==find(i))continue;
            for(int k=0;k<v[y].size();k++){
                int xx=i,yy=v[y][k];
                if(xx>yy)swap(xx,yy);
                if(s.find(make_pair(xx,yy))==s.end()){
                    int xxx=find(i),yyy=y;
                    if(sz[xxx]>sz[yyy])swap(xxx,yyy);
                    ans++;f[xxx]=yyy;sz[yyy]+=sz[xxx];
                    que[++tp]=xxx;
                    for(int l=0;l<v[xxx].size();l++)v[yyy].push_back(v[xxx][l]);v[xxx].clear();
                    break;
                }
            }
        }
        while(tp)st.erase(que[tp--]);
    }
    printf("%d\n",n-1-ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector < int >
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define maxx ((int)1e6 + 7)
#define mod ((int)1e9 + 7)
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define eps 1e-9
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
//int spf[(int)1e6];
//void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
//bool prime[(int)((1e7) + 20)];
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int bin(int x,int y,int z){int res=1;while(y>0){if(y%2==1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res%z;}
// int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
// int fact[1000007]={0};
// void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res; }
// #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
set < int > adj[1000000];
// bool vis[1000000];
set < int > un;
void dfs(int x)
{
	un.erase(x);
	vector < int > nex;
	for(auto z : un)
	{
		if(adj[x].find(z) == adj[x].end())
			nex.pb(z);
	}
	for(auto e : nex)
		un.erase(e);
	for(auto e : nex)
		dfs(e);
}
int32_t main()
{
	fast_io
	int n, m, x, y;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	// set < int > un;
	for(int i = 1; i <= n; i++)
		un.insert(i);
	int ans = 0;
	while(un.size() != 0)
	{
		ans++;
		int x = *un.begin();
		dfs(x);
		// queue < int > q;
		// q.push(x);
		// int z;
		// while(!q.empty())
		// {
		// 	z = q.front();
		// 	un.erase(z);
		// 	q.pop();
		// 	for(auto k : un)
		// 		if(adj[z].find(k) == adj[z].end())
		// 			q.push(k);
		// }
	}
	cout << ans - 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector < int >
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define maxx ((int)1e6 + 7)
#define mod ((int)1e9 + 7)
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define eps 1e-9
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
//int spf[(int)1e6];
//void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
//bool prime[(int)((1e7) + 20)];
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int bin(int x,int y,int z){int res=1;while(y>0){if(y%2==1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res%z;}
// int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
// int fact[1000007]={0};
// void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res; }
// #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
set < int > adj[1000000];
bool vis[1000000];
set < int > un;
void dfs(int x)
{
	un.erase(x);
	for(auto z : un)
	{
		if(adj[x].find(z) == adj[x].end())
			dfs(z);
	}
}
int32_t main()
{
	fast_io
	int n, m, x, y;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	// set < int > un;
	for(int i = 1; i <= n; i++)
		un.insert(i);
	int ans = 0;
	while(un.size() != 0)
	{
		ans++;
		int x = *un.begin();
		dfs(x);
		// queue < int > q;
		// q.push(x);
		// int z;
		// while(!q.empty())
		// {
		// 	z = q.front();
		// 	un.erase(z);
		// 	q.pop();
		// 	for(auto k : un)
		// 		if(adj[z].find(k) == adj[z].end())
		// 			q.push(k);
		// }
	}
	cout << ans - 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector < int >
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define maxx ((int)1e6 + 7)
#define mod ((int)1e9 + 7)
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define eps 1e-9
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
//int spf[(int)1e6];
//void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
//bool prime[(int)((1e7) + 20)];
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int bin(int x,int y,int z){int res=1;while(y>0){if(y%2==1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res%z;}
// int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
// int fact[1000007]={0};
// void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res; }
// #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
set < int > adj[1000000];
// bool vis[1000000];
set < int > un;
void dfs(int x)
{
	un.erase(x);
	for(auto z : un)
	{
		if(adj[x].find(z) == adj[x].end())
			dfs(z);
	}
}
int32_t main()
{
	fast_io
	int n, m, x, y;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	// set < int > un;
	for(int i = 1; i <= n; i++)
		un.insert(i);
	int ans = 0;
	while(un.size() != 0)
	{
		ans++;
		int x = *un.begin();
		dfs(x);
		// queue < int > q;
		// q.push(x);
		// int z;
		// while(!q.empty())
		// {
		// 	z = q.front();
		// 	un.erase(z);
		// 	q.pop();
		// 	for(auto k : un)
		// 		if(adj[z].find(k) == adj[z].end())
		// 			q.push(k);
		// }
	}
	cout << ans - 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector < int >
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define maxx ((int)1e6 + 7)
#define mod ((int)1e9 + 7)
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define eps 1e-9
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
//int spf[(int)1e6];
//void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
//bool prime[(int)((1e7) + 20)];
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int bin(int x,int y,int z){int res=1;while(y>0){if(y%2==1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res%z;}
// int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
// int fact[1000007]={0};
// void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {facto(); int res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res; }
// #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
set < int > adj[1000000];
// bool vis[1000000];
set < int > un;
void dfs(int x)
{
	un.erase(x);
	vector < int > nex;
	for(auto z : un)
	{
		if(adj[x].find(z) == adj[x].end())
			nex.pb(z);
	}
	// for(auto e : nex)
	// 	un.erase(e);
	for(auto e : nex)
		dfs(e);
}
int32_t main()
{
	fast_io
	int n, m, x, y;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	// set < int > un;
	for(int i = 1; i <= n; i++)
		un.insert(i);
	int ans = 0;
	while(un.size() != 0)
	{
		ans++;
		int x = *un.begin();
		dfs(x);
		// queue < int > q;
		// q.push(x);
		// int z;
		// while(!q.empty())
		// {
		// 	z = q.front();
		// 	un.erase(z);
		// 	q.pop();
		// 	for(auto k : un)
		// 		if(adj[z].find(k) == adj[z].end())
		// 			q.push(k);
		// }
	}
	cout << ans - 1 << endl;
}


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

#define int long long
const int N = 500005;

int n,m,t1,t2,fa[N],sz[N],bel[N],cnt[N];
vector <int> g[N];

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

void merge(int p,int q) {
    //p=find(q); q=find(q);
    if(p!=q) {
        fa[p]=q;
        sz[q]+=sz[p];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    vector <int> st;
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        cin>>t1>>t2;
        g[max(t1,t2)].push_back(min(t1,t2));
    }
    for(int i=1;i<=n;i++) {
        fa[i]=i;
        sz[i]=1;
    }
    for(int i=1;i<=n;i++) {
        for(int j:g[i]) ++cnt[find(j)];
        for(int j:st) {
            if(find(i)==find(j)) continue;
            if(cnt[j]<sz[j]) merge(i,j);
        }
        for(int j:g[i]) --cnt[find(j)];
        if(find(i)==i) st.push_back(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(find(i)==i) ++ans;
    cout<<ans-1;
}


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

#define int long long
const int N = 1000005;

vector <int> g[N];
int n,m,t1,t2,c[N],s[N],x[N],ind;

signed main() {
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        cin>>t1>>t2;
        if(t1>t2) swap(t1,t2);
        g[t2].push_back(t1);
    }
    for(int i=1;i<=n;i++) {
        int fg=1;
        for(int j=1;j<=ind;j++) x[j]=0;
        for(int q:g[i]) x[c[q]]++;
        for(int j=1;j<=ind;j++) {
            if(x[j]<s[j]) {
                s[j]++;
                c[i]=j;
                fg=0;
                break;
            }
        }
        if(fg) {
            ++ind;
            c[i]=ind;
            s[i]=1;
        }
    }
    cout<<ind-1;
}


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

#define int long long
const int N = 500005;

int n,m,t1,t2,fa[N],sz[N],bel[N];
vector <int> g[N];

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

void merge(int p,int q) {
    p=find(p); q=find(q);
    if(p!=q) {
        fa[p]=q;
        sz[q]+=sz[p];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    vector <int> st;
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        cin>>t1>>t2;
        g[max(t1,t2)].push_back(min(t1,t2));
    }
    for(int i=1;i<=n;i++) {
        fa[i]=i;
        sz[i]=1;
    }
    for(int i=1;i<=n;i++) {
        map<int,int> cnt;
        for(int j:g[i]) cnt[find(j)]++;
        for(int j:st) {
            if(find(i)==find(j)) continue;
            if(cnt[find(j)]<sz[find(j)]) merge(i,j);
        }
        if(find(i)==i) st.push_back(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(find(i)==i) ++ans;
    cout<<ans-1;
}


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

#define int long long
const int N = 500005;

int n,m,t1,t2,fa[N],sz[N],bel[N];
vector <int> g[N];

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

void merge(int p,int q) {
    //p=find(q); q=find(q);
    if(p!=q) {
        fa[p]=q;
        sz[q]+=sz[p];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    vector <int> st;
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        cin>>t1>>t2;
        g[max(t1,t2)].push_back(min(t1,t2));
    }
    for(int i=1;i<=n;i++) {
        fa[i]=i;
        sz[i]=1;
    }
    for(int i=1;i<=n;i++) {
        map<int,int> cnt;
        for(int j:g[i]) ++cnt[find(j)];
        for(int j:st) {
            if(find(i)==find(j)) continue;
            if(cnt[find(j)]<sz[find(j)]) merge(i,j);
        }
        if(find(i)==i) st.push_back(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(find(i)==i) ++ans;
    cout<<ans-1;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define int long long
using namespace std;
inline int read(){
	int w=0,x=0;char c=getchar();
	while(!isdigit(c))w|=c=='-',c=getchar();
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return w?-x:x;
}
namespace star
{
	const int maxn=1e5+10;
	int n,m,fa[maxn],siz[maxn],ecnt,head[maxn],to[maxn],nxt[maxn],q[maxn],tot,but[maxn],tim[maxn];
	inline void addedge(int a,int b){
		to[++ecnt]=b,nxt[ecnt]=head[a],head[a]=ecnt;
	}
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	inline void onion(const int &x,const int &y){
		int fx=find(x),fy=find(y);
		if(fx==fy)return;
		if(but[fy]<siz[fy])fa[fx]=fy,siz[fy]+=siz[fx];
	}
	inline void work(){
		n=read(),m=read();
		for(int i=1;i<=m;i++){
			int x=read(),y=read();
			if(x>y)swap(x,y);
			addedge(y,x);
		}
		for(int i=1;i<=n;i++)fa[i]=i,siz[i]=1;
		for(int i=1;i<=n;i++){
			for(int j=head[i];j;j=nxt[j]){
				int u=find(to[j]);
				if(tim[u]==i)but[u]++;
				else tim[u]=i,but[u]=1;
			}
			for(int j=1;j<=tot;j++)onion(i,q[j]);
			if(find(i)==i)q[++tot]=i;
		}
		int ans=-1;
		for(int i=1;i<=n;i++)ans+=find(i)==i;
		printf("%lld",ans);
	}
}
signed main(){
	star::work();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define int long long
using namespace std;
inline int read(){
	int w=0,x=0;char c=getchar();
	while(!isdigit(c))w|=c=='-',c=getchar();
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return w?-x:x;
}
namespace star
{
	const int maxn=1e5+10;
	int n,m,fa[maxn],siz[maxn],ecnt,head[maxn],to[maxn],nxt[maxn],q[maxn],tot,but[maxn],tim[maxn];
	inline void addedge(int a,int b){
		to[++ecnt]=b,nxt[ecnt]=head[a],head[a]=ecnt;
	}
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	inline void onion(const int &x,const int &y){
		int fx=find(x),fy=find(y);
		if(fx==fy)return;
		if(tim[fy]!=x or but[fy]<siz[fy])fa[fx]=fy,siz[fy]+=siz[fx];
	}
	inline void work(){
		n=read(),m=read();
		for(int i=1;i<=m;i++){
			int x=read(),y=read();
			if(x>y)swap(x,y);
			addedge(y,x);
		}
		for(int i=1;i<=n;i++)fa[i]=i,siz[i]=1;
		for(int i=1;i<=n;i++){
			for(int j=head[i];j;j=nxt[j]){
				int u=find(to[j]);
				if(tim[u]==i)but[u]++;
				else tim[u]=i,but[u]=1;
			}
			for(int j=1;j<=tot;j++)onion(i,q[j]);
			if(find(i)==i)q[++tot]=i;
		}
		int ans=-1;
		for(int i=1;i<=n;i++)ans+=find(i)==i;
		printf("%lld",ans);
	}
}
signed main(){
	star::work();
	return 0;
}
/*
6 9
1 2
1 4
1 5
2 3
2 5
2 6
3 5
4 6
*/


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
inline int read(){
	int w=0,x=0;char c=getchar();
	while(!isdigit(c))w|=c=='-',c=getchar();
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return w?-x:x;
}
namespace star
{
	const int maxn=1e5+10;
	int n,m,fa[maxn],siz[maxn],ecnt,head[maxn],to[maxn],nxt[maxn],q[maxn],tot,but[maxn],tim[maxn];
	inline void addedge(int a,int b){
		to[++ecnt]=b,nxt[ecnt]=head[a],head[a]=ecnt;
	}
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	inline void onion(const int &x,const int &y){
		int fx=find(x),fy=find(y);
		if(fx==fy)return;
		if(but[fy]<siz[fy])fa[fx]=fy,siz[fy]+=siz[fx];
	}
	inline void work(){
		n=read(),m=read();
		for(int i=1;i<=m;i++){
			int x=read(),y=read();
			if(x>y)swap(x,y);
			addedge(y,x);
		}
		for(int i=1;i<=n;i++)fa[i]=i,siz[i]=1;
		for(int i=1;i<=n;i++){
			for(int j=head[i];j;j=nxt[j]){
				int u=find(to[j]);
				if(tim[u]==i)but[u]++;
				else tim[u]=i,but[u]=1;
			}
			for(int j=1;j<=tot;j++)onion(i,q[j]);
			if(find(i)==i)q[++tot]=i;
		}
		int ans=-1;
		for(int i=1;i<=n;i++)ans+=find(i)==i;
		printf("%d",ans);
	}
}
signed main(){
	star::work();
	return 0;
}