//
//  main.cpp
//  pingpong
//
//  Created by Mm on 9/27/18.
//  Copyright © 2018 Mm. All rights reserved.
//

#include <vector>
#include <iostream>

using namespace std;

long long a[105];
long long b[105];
bool visited[105];
long long at = 1;

void dfs(long long index){
    visited[index] = true;

    for(int undex = 1; undex < at+1; undex++){
        if(!visited[undex]){
            if(a[index] > a[undex] && a[index] < b[undex]){
                dfs(undex);
            }else if(b[index] > a[undex] && b[index] < b[undex]){
                dfs(undex);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    long long n;
    cin >> n;

    for(int i = 0; i < n; i++){
        long long goingTo;
        long long x;
        long long y;
        cin >> goingTo >> x >> y;

        if(goingTo == 1){
            a[at] = x;
            b[at] = y;
            at++;
        }else{
            memset(visited, false, sizeof(visited));
            dfs(x);
            if (visited[y]){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }
    }

    return 0;
}


//
//  main.cpp
//  pingpong
//
//  Created by Mm on 9/27/18.
//  Copyright © 2018 Mm. All rights reserved.
//

#include <vector>
#include <iostream>

using namespace std;

long long a[105];
long long b[105];
bool visited[105];
long long at = 1;

void dfs(long long index){
    visited[index] = true;

    for(int undex = 1; undex < at+1; undex++){
        if(!visited[undex]){
            if(a[index] > a[undex] && a[index] < b[undex]){
                dfs(undex);
            }else if(b[index] > a[undex] && b[index] < b[undex]){
                dfs(undex);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    long long n;
    cin >> n;

    for(int i = 0; i < n; i++){
        long long goingTo;
        long long x;
        long long y;
        cin >> goingTo >> x >> y;

        if(goingTo == 1){
            a[at] = x;
            b[at] = y;
            at++;
        }else{
            int size = sizeof(visited);
            visited[size] = false;
            dfs(x);
            if (visited[y]){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }
    }

    return 0;
}


//
//  main.cpp
//  pingpong
//
//  Created by Mm on 9/27/18.
//  Copyright © 2018 Mm. All rights reserved.
//

#include <vector>
#include <iostream>

using namespace std;

long long a[105];
long long b[105];
bool visited[105];
long long at = 1;

void dfs(long long index){
    visited[index] = true;

    for(int undex = 1; undex < at+1; undex++){
        if(!visited[undex]){
            if(a[index] > a[undex] && a[index] < b[undex]){
                dfs(undex);
            }else if(b[index] > a[undex] && b[index] < b[undex]){
                dfs(undex);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    long long n;
    cin >> n;

    for(int i = 0; i < n; i++){
        long long goingTo;
        long long x;
        long long y;
        cin >> goingTo >> x >> y;

        if(goingTo == 1){
            a[at] = x;
            b[at] = y;
            at++;
        }else{
            memset(visited, false, sizeof(visited));
            dfs(x);

            if (visited[y]){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }
    }

    return 0;
}


//
//  main.cpp
//  pingpong
//
//  Created by Mm on 9/27/18.
//  Copyright © 2018 Mm. All rights reserved.
//

#include <vector>
#include <iostream>
#include <cstring>

using namespace std;

long long a[105];
long long b[105];
bool visited[105];
long long at = 1;

void dfs(long long index){
    visited[index] = true;

    for(int undex = 1; undex < at+1; undex++){
        if(!visited[undex]){
            if(a[index] > a[undex] && a[index] < b[undex]){
                dfs(undex);
            }else if(b[index] > a[undex] && b[index] < b[undex]){
                dfs(undex);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    long long n;
    cin >> n;

    for(int i = 0; i < n; i++){
        long long goingTo;
        long long x;
        long long y;
        cin >> goingTo >> x >> y;

        if(goingTo == 1){
            a[at] = x;
            b[at] = y;
            at++;
        }else{
            memset(visited, false, sizeof(visited));

            mem(visited, false);
            dfs(x);
            if (visited[y]){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }
    }

    return 0;
}


//
//  main.cpp
//  pingpong
//
//  Created by Mm on 9/27/18.
//  Copyright © 2018 Mm. All rights reserved.
//

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

long long a[105];
long long b[105];
bool visited[105];
long long at = 1;

void dfs(long long index){
    visited[index] = true;

    for(int undex = 1; undex < at+1; undex++){
        if(!visited[undex]){
            if(a[index] > a[undex] && a[index] < b[undex]){
                dfs(undex);
            }else if(b[index] > a[undex] && b[index] < b[undex]){
                dfs(undex);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    long long n;
    cin >> n;

    for(int i = 0; i < n; i++){
        long long goingTo;
        long long x;
        long long y;
        cin >> goingTo >> x >> y;

        if(goingTo == 1){
            a[at] = x;
            b[at] = y;
            at++;
        }else{
            memset(visited, false, sizeof(visited));
            dfs(x);
            if (visited[y]){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,path[101],p,q,t, a[101],b[101];
void dfs(int v)
{
if(path[v])  return;
path[v]=1;

for(int i=1;i<=n;i++)

   {

   if(!path[i]){
    if(a[v]>a[i] && a[v]<b[i] || b[v]>a[i] && b[v]<b[i])
        {dfs(i);}}}
        }

int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
    cin>>t;
    if(t==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {for(i=0;i<=n;i++)
  {
      path[i]=0;}

        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
void dfs(int v)
{path[v]=1;//cout<<v;
if(v==q) return ;
for(k=1;k<=n;k++)
    if(a[v]>a[k] && a[v]<b[k] && !path[k] || b[v]>a[k] && b[v]<b[k] && !path[k])
        {dfs(k);
        }}

int main()
{
cin>>n;
for(i=0;i<n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,101);
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
int dfs(int v)
{path[v]=1;
if(v==q) return 1;

for(k=1;k<=j;k++)
    if(a[v]>a[k] && a[v]<b[k] || b[v]>a[k] && b[v]<b[k])
        {dfs(k); cout<<"yayy";}}

int main()
{
cin>>n;
for(i=0;i<n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {
        cin>>p>>q;
        dfs(p);
        memset(path,0,101);
        if(path[q])
            cout<<"YES";
        else
            cout<<"NO";
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
void dfs(int i)
{path[i]=1;//cout<<v;
if(i==q) return ;
for(k=1;k<=n;k++)
    if(a[i]>a[k] && a[i]<b[k] && !path[k])
        dfs(k);
        else if(b[i]>a[k] && b[i]<b[k] && !path[k])
        {dfs(k);
        }}

int main()
{
cin>>n;
for(i=1;i<=n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,101);
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
int dfs(int v)
{path[v]=1;
for(k=1;k<=j;k++)
    if(a[v]>a[k] && a[v]<b[k] || b[v]>a[k] && b[v]<b[k])
        dfs(k);}

int main()
{
cin>>n;
for(i=0;i<n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {
        cin>>p>>q;
        dfs(p);
        memset(path,0,101);
        if(path[q]==1)
            cout<<"YES";
        else
            cout<<"NO";
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
int dfs(int v)
{path[v]=1;//cout<<v;
if(v==q) return 1;

for(k=1;k<=j;k++)
    if(a[v]>a[k] && a[v]<b[k] && !path[k] || b[v]>a[k] && b[v]<b[k] && !path[k])
        {dfs(k);// cout<<"yayy";
        }}

int main()
{
cin>>n;
for(i=0;i<n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,101);
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES";
        else
            cout<<"NO";
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
int dfs(int v)
{path[v]=1;//cout<<v;
if(v==q) return 1;

for(k=1;k<=j;k++)
    if(a[v]>a[k] && a[v]<b[k] && !path[k] || b[v]>a[k] && b[v]<b[k] && !path[k])
        {dfs(k);// cout<<"yayy";
        }}

int main()
{
cin>>n;
for(i=0;i<n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,101);
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
void dfs(int i)
{path[i]=1;//cout<<v;
for(k=1;k<=n;k++)
    if(a[i]>a[k] && a[i]<b[k] && !path[k])
        dfs(k);
        else if(b[i]>a[k] && b[i]<b[k] && !path[k])
        {dfs(k);
        }}

int main()
{
cin>>n;
for(i=1;i<=n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,101);
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,path[101],p,q,t, a[101],b[101];
void dfs(int v)
{
if(path[v])  return;
path[v]=1;

for(int i=1;i<=n;i++)

   {

   if(!path[i]){
    if(a[v]>a[i] && a[v]<b[i] || b[v]>a[i] && b[v]<b[i])
        {dfs(i);}}}
        }

int main()
{
cin>>n;
for(int k=1;k<=n;k++)
{
    cin>>t;
    if(t==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {for(int l=0;l<=n;l++)
  {
      path[l]=0;}

        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m, a[101],b[101];
void dfs(int i)
{path[i]=1;//cout<<v;
for(k=1;k<=n;k++)
   {
    if(!path[k])
        continue;
    if(a[i]>a[k] && a[i]<b[k])
        dfs(k);
        else if(b[i]>a[k] && b[i]<b[k])
        {dfs(k);
        }}}

int main()
{
cin>>n;
for(i=1;i<=n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,sizeof(path));
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,path[101],p,q,t, a[101],b[101];
void dfs(int v)
{
if(path[v])  return;
path[v]=1;

for(int i=1;i<=n;i++)

   {

   if(!path[i]){
    if(a[v]>a[i] && a[v]<b[i] || b[v]>a[i] && b[v]<b[i])
        {dfs(i);}}}
        }

int main()
{
cin>>n;
for(int k=1;k<=n;k++)
{
    cin>>t;
    if(t==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {for(int i=0;i<=n;i++)
  {
      path[i]=0;}

        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include<bits/stdc++.h>
using namespace std;
int n,j=0,k,path[101],p,q,i,m;
long long int a[101],b[101];
void dfs(int i)
{path[i]=1;//cout<<v;
if(i==q) return ;
for(k=1;k<=n;k++)
    if(a[i]>a[k] && a[i]<b[k] && !path[k] || b[i]>a[k] && b[i]<b[k] && !path[k])
        {dfs(k);
        }}

int main()
{
cin>>n;
for(i=0;i<n;i++)
{
    cin>>m;
    if(m==1)
    {j++;
        cin>>a[j]>>b[j];
    }
    else
    {memset(path,0,101);
        cin>>p>>q;
        dfs(p);

        if(path[q]==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
}


#include <iostream>

using namespace std;
using interval = pair<int, int>;

#define MAX_QUERIES 101

bool can_move(interval a, interval b) {
  return ((a.first > b.first && a.first < b.second) || (a.second > b.first && a.second < b.second));
}

int main() {
  int n;
  cin >> n;
  int size = 0;
  interval intervals[MAX_QUERIES];
  bool connected[MAX_QUERIES][MAX_QUERIES];
  for (int i = 0; i < MAX_QUERIES; ++i) {
    for (int j = 0; j < MAX_QUERIES; ++j) {
      if (i != j) {
        connected[i][j] = false;
      } else {
        connected[i][j] = true;
      }
    }
  }
  while (n--) {
    int q;
    cin >> q;
    if (q == 1) {
      int x, y;
      cin >> x >> y;
      interval new_interval(x, y);
      // check for direct connections
      for (int i = 0; i < size; ++i) {
        if (can_move(new_interval, intervals[i])) {
          connected[size][i] = true;
        }
        if (can_move(intervals[i], new_interval)) {
          connected[i][size] = true;
        }
      }
      ++size;
      // check for indirect connections
      for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
          for (int k = 0; k < size; ++k) {
            if (connected[j][i] && connected[i][k]) {
              connected[j][k] = true;
            }
          }
        }
      }
      // add the new interval
      intervals[size - 1].first = new_interval.first;
      intervals[size - 1].second = new_interval.second;
    } else {
      int a, b;
      cin >> a >> b;
      if (connected[a - 1][b - 1]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
}


#include <iostream>

using namespace std;
using interval = pair<int, int>;

#define MAX_QUERIES 101

bool can_move(interval a, interval b) {
  return ((b.first > a.first && b.first < a.second) || (b.second > a.first && b.second < a.second));
}

int main() {
  int n;
  cin >> n;
  int size = 0;
  interval intervals[MAX_QUERIES];
  bool connected[MAX_QUERIES][MAX_QUERIES];
  while (n--) {
    int q;
    cin >> q;
    if (q == 1) {
      int x, y;
      cin >> x >> y;
      interval new_interval(x, y);
      // check for direct connections
      for (int i = 0; i < size; ++i) {
        if (can_move(new_interval, intervals[i])) {
          connected[size][i] = true;
        }
        if (can_move(intervals[i], new_interval)) {
          connected[i][size] = true;
        }
      }
      ++size;
      // check for indirect connections
      for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
          for (int k = 0; k < size; ++k) {
            if (connected[j][i] && connected[i][k]) {
              connected[j][k] = true;
            }
          }
        }
      }
      // add the new interval
      intervals[size - 1].first = new_interval.first;
      intervals[size - 1].second = new_interval.second;
    } else {
      int a, b;
      cin >> a >> b;
      if (connected[a - 1][b - 1]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
}


#include <iostream>

using namespace std;
using interval = pair<int, int>;

#define MAX_QUERIES 101

bool can_move(interval a, interval b) {
  return ((b.first > a.first && b.first < a.second) || (b.second > a.first && b.second < a.second));
}

int main() {
  int n;
  cin >> n;
  int size = 0;
  interval intervals[MAX_QUERIES];
  bool connected[MAX_QUERIES][MAX_QUERIES];
  while (n--) {
    int q;
    cin >> q;
    if (q == 1) {
      int x, y;
      cin >> x >> y;
      interval new_interval(x, y);
      // check for direct connections
      for (int i = 0; i < size; ++i) {
        if (can_move(new_interval, intervals[i])) {
          connected[size][i] = true;
        }
        if (can_move(intervals[i], new_interval)) {
          connected[i][size] = true;
        }
      }
      ++size;
      // check for indirect connections
      for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
          for (int k = 0; k < size; ++k) {
            if (connected[j][i] && connected[i][k]) {
              connected[j][k] = true;
            }
          }
        }
      }
      // add the new interval
      intervals[size - 1].first = new_interval.first;
      intervals[size - 1].second = new_interval.second;
    } else {
      int a, b;
      cin >> a >> b;
      if (connected[a][b]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
}


#include <iostream>

using namespace std;
using interval = pair<int, int>;

#define MAX_QUERIES 101

bool can_move(interval a, interval b) {
  return ((b.first > a.first && b.first < a.second) || (b.second > a.first && b.second < a.second));
}

int main() {
  int n;
  cin >> n;
  int size = 0;
  interval intervals[MAX_QUERIES];
  bool connected[MAX_QUERIES][MAX_QUERIES];
  for (int i = 0; i < MAX_QUERIES; ++i) {
    for (int j = 0; j < MAX_QUERIES; ++j) {
      connected[i][j] = false;
    }
  }
  while (n--) {
    int q;
    cin >> q;
    if (q == 1) {
      int x, y;
      cin >> x >> y;
      interval new_interval(x, y);
      // check for direct connections
      for (int i = 0; i < size; ++i) {
        if (can_move(new_interval, intervals[i])) {
          connected[size][i] = true;
        }
        if (can_move(intervals[i], new_interval)) {
          connected[i][size] = true;
        }
      }
      ++size;
      // check for indirect connections
      for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
          for (int k = 0; k < size; ++k) {
            if (connected[j][i] && connected[i][k]) {
              connected[j][k] = true;
            }
          }
        }
      }
      // add the new interval
      intervals[size - 1].first = new_interval.first;
      intervals[size - 1].second = new_interval.second;
    } else {
      int a, b;
      cin >> a >> b;
      if (connected[a - 1][b - 1]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
}


#include <iostream>

using namespace std;
using interval = pair<int, int>;

#define MAX_QUERIES 101

bool can_move(interval a, interval b) {
  return ((b.first > a.first && b.first < a.second) || (b.second > a.first && b.second < a.second));
}

int main() {
  int n;
  cin >> n;
  int size = 0;
  interval intervals[MAX_QUERIES];
  bool connected[MAX_QUERIES][MAX_QUERIES];
  while (n--) {
    int q;
    cin >> q;
    if (q == 1) {
      int x, y;
      cin >> x >> y;
      interval new_interval(x, y);
      // check for direct connections
      for (int i = 0; i < size; ++i) {
        if (can_move(new_interval, intervals[i])) {
          connected[size][i] = true;
        }
        if (can_move(intervals[i], new_interval)) {
          connected[i][size] = true;
        }
      }
      ++size;
      // check for indirect connections
      for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
          for (int k = 0; k < size; ++k) {
            if (connected[i][k] && connected[k][j]) {
              connected[i][j] = true;
            }
          }
        }
      }
      // add the new interval
      intervals[size - 1].first = new_interval.first;
      intervals[size - 1].second = new_interval.second;
    } else {
      int a, b;
      cin >> a >> b;
      if (connected[a - 1][b - 1]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
}


#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
#define N 1005
queue<int> q;
struct Node
{
    int l,r;
}a[N];
struct Node1
{
    int to,next;
}e[N];
int tot;
int head[N];
int vis[N];
void add(int from, int to) {
	e[tot].to = to;
	e[tot].next = head[from];
	head[from] = tot++;
}
bool bfs(int x,int y)
{
    q.push(x);
    int s;
    while(!q.empty())
    {
        s=q.front();
        if(s==y)return true;
        q.pop();
        for(int i=head[s];i>=0;i=e[i].next)
        {
            int ss=e[i].to;
            if(vis[ss]==0)
            {
                q.push(ss);
                vis[ss]=1;
            }

        }
    }
    return false;
}
int main()
{
    memset(head,-1,sizeof(head));
    int n;
    scanf("%d",&n);
    int p=1;
    int f=1;
    for(int i=0;i<n;i++)
    {
        int k,x,y;
        scanf("%d%d%d",&k,&x,&y);
        if(k==1)
        {
            a[p].l=x;
            a[p].r=y;
            p++;
            int flag=1;
            for(int j=1;j<p-1;j++)
            {
                if(x>a[j].l&&x<a[j].r||y>a[j].l&&y<a[j].r)
                {
                    add(j,p-1);
                    add(p-1,j);
                }
            }
        }
        if(k==2)
        {
            if(bfs(x,y))
            {
                printf("YES\n");
            }
            else printf("NO\n");
            for(int j=1;j<p;j++)
            {
                vis[j]=0;
            }
        }
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n,x[128],y[128],vis[128];
bool reach(int at,int t){
	if(vis[at])return false;
	vis[at]=1;
	if(at==t)return true;
	rep(i,n){
		if((x[i]<x[at]&&x[at]<y[i])||(x[i]<y[at]&&y[at]<y[i])){
            if(reach(i,t))return true;
        }
	}
	return false;
}
int main(){
	int q;
	cin>>q;
	rep(i,q){
		int ty,a,b;
		cin>>ty>>a>>b;
		if(ty==1){
			x[n]=a;
			y[n]=b;
			n++;
		}
		else{
			a--,b--;
			memset(vis,0,sizeof(vis));
			if(reach(a,b))cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}


#include<stdio.h>///CF320B
struct node///单向 cabd a,b -> c,d   || (a,c,b,d||c,a,d,b) a,b<->c,d
{
    int x,y;
}a[105];
int dx[105];
int dx1[105];
int _find(int x)
{
    if(dx[x] == x)
        return x;
    return dx[x] = _find(dx[x]);
}
int main()
{
    int n;
    scanf("%d",&n);
    int jsq = 0;
    for(int i = 1 ; i <= n; i++)
    {
        int op,l,r;
        scanf("%d%d%d",&op,&l,&r);
        if(op == 1)
        {
            dx[++jsq] = jsq;
            dx1[jsq] = jsq;
            a[jsq].x = l;
            a[jsq].y = r;
            for(int j = 1; j < jsq; j++)
            {
                if( a[j].x < l && a[j].y < r && l < a[j].y || l < a[j].x && a[j].x < r && r < a[j].y )
                    dx[_find(jsq)] = _find(j);
                else if( a[j].x < l && a[j].y > r)
                    dx1[_find(j)] = jsq;
            }///那个是高坂京介,
        }
        else
        {
            if(_find(l) == _find(r) || dx1[_find(l)] == r)///1.互通  2.a->b
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num=0;
int visit[1001];
struct INTERVAL
{
	int s,t;
}f[1001];
void dfs(int x)
{
	visit[x]=1;
	for(int i=0;i<num;i++)
	{
		if((f[i].s<f[x].s && f[x].s<f[i].t) || (f[i].s<f[x].t && f[x].t<f[i].t) && !visit[i])
			dfs(i);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	int a,b,c;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		if(a==1)
		{
			f[num].s=b;
			f[num].t=c;
			num++;
		}
		else
		{
			--b,--c;
			for(int j=0;j<num;j++)
			{
				visit[j]=0;
			}
			dfs(b);
			if(visit[c])
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int m=0,a[105],b[105];
bool vis[105],flag=0;
void dfs(int begin)
{
	for(int i=0;i<m;i++)
	{
		if(vis[i])continue;
		if((a[begin]>a[i]&&a[begin]<b[i])||(b[begin]>a[i]&&b[begin]<b[i]))
		{
			vis[i]=1;
			dfs(i);
		}
	}
}
int main()
{
	int n,k,c,d;
	cin>>n;
	while(n--)
	{
		cin>>k>>c>>d;
		if(k==1) {a[m++]=c,b[m]=d;}
		if(k==2)
		 {
		 	memset(vis,0,sizeof(vis));
		 	vis[c]=1;
			 dfs(c);
			 if(vis[d]) cout<<"YES"<<endl;
			 else cout<<"NO"<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int m=0,a[105],b[105];
bool vis[105],flag=0;
void dfs(int begin)
{
	vis[begin]=1;
	for(int i=1;i<=m;i++)
	{
		if(vis[i])continue;
		if((a[begin]>a[i]&&a[begin]<b[i])||(b[begin]>a[i]&&b[begin]<b[i]))
		{
			dfs(i);
		}
	}
}
int main()
{
	int n,k,c,d;
	cin>>n;
	while(n--)
	{
		cin>>k>>c>>d;
		if(k==1) {a[++m]=c,b[m]=d;}
		if(k==2)
		 {
		 	memset(vis,0,sizeof(vis));
			 dfs(c);
			 if(vis[d]) cout<<"YES"<<endl;
			 else cout<<"NO"<<endl;
		}
	}
	return 0;
}


#include<stdio.h>///CF320B
struct node///单向 cabd a,b -> c,d   || (a,c,b,d||c,a,d,b) a,b<->c,d
{
    int x,y;
}a[105];
int dx[105];
int dx1[105];
int _find(int x)
{
    if(dx[x] == x)
        return x;
    return dx[x] = _find(dx[x]);
}
int main()
{
    int n;
    scanf("%d",&n);
    int jsq = 0;
    for(int i = 1 ; i <= n; i++)
    {
        int op,l,r;
        scanf("%d%d%d",&op,&l,&r);
        if(op == 1)
        {
            dx[++jsq] = jsq;
            dx1[jsq] = jsq;
            a[jsq].x = l;
            a[jsq].y = r;
            for(int j = 1; j < jsq; j++)
            {//printf("j&jsq:%d %d a[%d]:%d %d jsq: %d %d\n",j,jsq,j,a[j].x,a[j].y,l,r);printf("%d\n",(a[j].x < l && l < a[j].y ) || (l < a[j].x && a[j].x < r ));
               if( a[j].x > l && a[j].y < r)
                    {dx1[_find(j)] = jsq;}
                else  if( (a[j].x < l && l < a[j].y ) || (l < a[j].x && a[j].x < r ) )
                    {dx[_find(jsq)] = _find(j);}

            }///那个是高坂京介,
          //  for(int j = 1; j <= 20; j++)
          //      printf("%d ",dx[j]);
          //  printf("\n");
           // for(int j = 1; j <= 20; j++)
           //     printf("%d ",dx1[j]);
           // printf("\n");
        }
        else
        {
            if(_find(l) == _find(r) || dx1[_find(l)] == r)///1.互通  2.a->b
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int m=0,a[105],b[105];
bool vis[105],flag=0;
void dfs(int begin,int last)
{
	if(flag==1) return;
	if(begin==last) {cout<<"YES"<<endl;flag=1;return;}
	for(int i=0;i<m;i++)
	{
		if(vis[i])continue;
		if((a[begin]>a[i]&&a[begin]<b[i])||(b[begin]>a[i]&&b[begin]<b[i]))
		{
			vis[i]=1;
			dfs(i,last);
			vis[i]=0;
		}
	}
}
int main()
{
	int n,k,c,d;
	cin>>n;
	while(n--)
	{
		cin>>k>>c>>d;
		if(k==1) {a[m++]=c,b[m]=d;}
		if(k==2)
		 {
		     flag=0;
			 dfs(c,d);
			 if(!flag) cout<<"NO"<<endl;
		}
		flag=0;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,t,x,y,p=0;
struct node
{
	int l,r;
}q[120];
bool v[120];
void dfs(int x)
{
	v[x]=1;
	for(int i=1;i<=p;i++)
	{
		node k=q[i];
		if(v[i]) continue;
		if((k.l<q[x].l&&q[x].l<k.r)||(k.l<q[x].r&&q[x].r<k.r)) dfs(i);
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>x>>y;
		if(t==1)
		{
			p++;
			q[p].l=x;
			q[p].r=y;
		}
		if(t==2)
		{
			memset(v,0,sizeof(v));
			dfs(x);
			if(v[y]==1) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}


// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
const int N=110;
int a[3][N];
vector<int> v[N];
bool F=0;
bool vis[110];
void dfs(int x) {
	vis[x]=1;
	for(int e=0;e!=v[x].size();e++) {
		if(vis[v[x][e]]==0) dfs(v[x][e],y);
	}
}
int main() {
	int n,k=0;
	cin>>n;
	while(n--) {
		int b;
		cin>>b;
		int x,y;
		cin>>x>>y;
		if(b==2) {
			memset(vis,0,sizeof vis);
			dfs(x);
			if(vis[y]==1) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else if(b==1) {
			a[1][++k]=x;
			a[2][k]=y;
			for(int i=1;i<k;i++) {
				if(a[1][i]>a[1][k] && a[1][i]<a[2][k] || a[2][i]>a[1][k] && a[2][i]<a[2][k])
					v[i].push_back(k);
				if(a[1][k]>a[1][i] && a[1][k]<a[2][i] || a[2][k]>a[1][i] && a[2][k]<a[2][i])
					v[k].push_back(i);
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int visit[1001];
int num=0;
vector<int> v[1001];
int n;
void dfs(int x)
{
	visit[x]=true;
	for(int i=0;i<num;i++)
	{
		if((v[i][0]<v[x][0] && v[x][1]<v[i][1]) || (v[i][0]<v[x][1] && v[x][1]<v[i][1]) && !visit[i])
			dfs(i);
	}
}
int main()
{
	cin>>n;
	int a,b,c;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		if(a==1)
		{
			v[num].push_back(b);
			v[num].push_back(c);
			num++;
		}
		if(a==2)
		{
			b--,c--;
			for(int i=0;i<num;i++)visit[i]=false;
			dfs(b);
			if(visit[c])
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
	}
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define add(a,b) v[a].pb(b)
using namespace std;
vector <int> v[105];
pair<int,int> a[105];
int t[105],cnt,mb,ans;
bool in(int x,int y){
	return (a[x].f<a[y].f&&a[y].f<a[x].s)||
	(a[x].f<a[y].s&&a[y].s<a[x].s);
}
void dfs(int p){
	if(t[p])return ;
	t[p]=1;
	if(p==mb){ans=1;return;}
	for(int i=0;i<v[p].size();i++)dfs(v[p][i]);
}
int main(){
	int n;
	cin>>n;
	int x,y,z;
	for(int i=0;i<n;i++){
		cin>>x>>y>>z;
		if(x==1){
			cnt++;
			a[cnt].f=y;
			a[cnt].s=z;
			for(int j=1;j<cnt;j++){
				if(in(j,cnt)){
					add(j,cnt);
				}
				if(in(cnt,j)){
					add(cnt,j);
				}
			}
		}else{
			ans=0;mb=z;
			memset(t,0,sizeof(t));
			dfs(y);
			if(ans){
				puts("YES");
			}else puts("NO");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num=0;
int visit[1001];
struct INTERVAL
{
	int s,t;
}f[1001];
void dfs(int x)
{
	visit[x]=1;
	for(int i=0;i<num;i++)
	{
		if((f[i].s<f[x].s && f[x].s<f[i].t) || (f[i].s<f[x].t && f[x].t<f[i].t) && !visit[i])
			dfs(i);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	scanf("%d",&n);
	int a,b,c;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		if(a==1)
		{
			f[num].s=b;
			f[num].t=c;
			num++;
		}
		else
		{
			--b,--c;
			for(int j=0;j<num;j++)
			{
				visit[j]=0;
			}
			dfs(b);
			if(visit[c])
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct query{
	int a,b;
}q[105];
bool vis[105];
int n,cnt;
void dfs(int x){
	vis[x]=1;
	for(int i=1;i<=cnt;i++){
		query y=q[i];
		if(vis[i])continue;
		if((y.a<q[x].a && q[x].a<y.b)||(y.a<q[x].b && q[x].b<y.b)) dfs(i);
	}
}
int main() {
	cin>>n;
	while(n--){
		int op,x,y;
		cin>>op>>x>>y;
		if(op==1)
			q[++cnt].a=x,q[cnt].b=y;
		if(op==2){
			for(int i=1;i<=100;i++)vis[i]=0;
			dfs(x);
			if(vis[y]) cout<<"YES\n";
			else cout<<"NO\n";
		}
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <math.h>
#include <string>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#define maxn  1000000
const int MaxN=0x3f3f3f3f;
const int MinN=0xc0c0c00c;
const double pi=acos(-1);
typedef long long ll;
const int mod=1e9+7;
using namespace std;
struct wazxy{
    int x,y;
}a[1000];
int iends,iflag,w;
bool visited[1000];
void dfs(int k){
    if(k==iends){
        iflag=true;
        return ;
    }
    else{
        for(int i=1;i<w;i++){
            if(visited[i]==true){
                visited[i]=false;
                if((a[k].x<a[i].y&&a[k].x>a[i].x)||(a[k].y<a[i].y&&a[k].y>a[i].x)){
                  //  cout<<i<<endl;
                    dfs(i);
                }
                visited[i]=true;
            }
        }
    }
    return ;
}
int main()
{
    int t;
    cin>>t;
    w=1;
    while(t--){
        int flag,x,y;
        scanf("%d%d%d",&flag,&x,&y);
        if(flag==1){
            a[w].x=x;
            a[w++].y=y;
        }
        else{
            iends=y;
            memset(visited,true,sizeof(visited));
            iflag=false;
            visited[x]=false;
            dfs(x);
            if(iflag==true) printf("YES\n");
            else  printf("NO\n");
        }
    }
    return 0;
}


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

const double pi=acos(-1.0);
double eps=0.000001;

int mp[105][105];
struct node
{
	int x,y;
	node(){}
	node(int a,int b)
	{x=a;y=b;}
} ;
node tm[105];

int vis[105];
	int n;
int dfs(int x,int y)
{
	vis[x]=1;
	if (x==y) return 1;
	int ret=0;int i;
	for (i=1;i<=n;i++)
	{
		if (mp[x][i]==0||vis[i]) continue;
		ret=dfs(i,y);
		if (ret) return 1;
	}
	return 0;
}
int main()
{
	int ok=0;
	cin>>n;
	int q,x,y;

	int i,j;
	for (i=1;i<=n;i++)
	{
		scanf("%d%d%d",&q,&x,&y);

		if (q==1)
		{
			tm[++ok]=node(x,y);
			for (j=1;j<ok;j++)
			{
				int flag=0;
				if (tm[ok].x<tm[j].x&&tm[j].x<tm[ok].y) flag=1;
				if (tm[ok].x<tm[j].y&&tm[j].y<tm[ok].y) flag=1;
				if (flag)
					mp[j][ok]=1;

				flag=0;
				if (tm[j].x<tm[ok].x&&tm[ok].x<tm[j].y) flag=1;
				if (tm[j].x<tm[ok].y&&tm[ok].y<tm[j].y) flag=1;
				if (flag)
					mp[ok][j]=1;
			}
		}
		else
		{
			memset(vis,0,sizeof(vis));
			if (dfs(x,y)) printf("YES\n");
			else printf("NO\n");

		}

	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int N = 110;
vector < pair <int , int> > iw;
vector < int > ad[N];
int a, b;
bool ok = 0;
bool mark[N];
void dfs(int v) {
	mark[v] = 1;
	if(v == b)
		ok = 1;
	for(int i = 0; i < ad[v].size(); i++)
	{
		if(mark[ad[v][i]] == 0)
		{
			dfs(ad[v][i]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	iw.push_back({0, 0});
	while(n--)
	{
		int x;
		cin >> x;
		if(x == 1)
		{
			pair <int , int> t;
			cin >> t.first >> t.second;
			iw.push_back(t);
			for(int i = 1; i < iw.size() ; i++)
			{
				if((t.first > iw[i].first && t.first < iw[i].second) || (t.second > iw[i].first && t.second < iw[i].second) )
				{
					ad[iw.size() - 1].push_back(i);
				}
				if((iw[i].first > t.first && iw[i].first < t.second) || (iw[i].second < t.second || iw[i].second > t.first))
				{
					ad[i].push_back(iw.size() - 1);
				}
			}
		}
		else
		{
			cin >> a >> b;
			dfs(a);
			if(ok)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
			ok = 0;
			for(int i = 0; i < N; i ++)
				mark[i] = 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 110;
vector < pair <int , int> > iw;
vector < int > ad[N];
int a, b;
bool ok = 0;
bool mark[N];
void dfs(int v) {
	mark[v] = 1;
	if(v == b)
		ok = 1;
	for(int i = 0; i < ad[v].size(); i++)
	{
		if(mark[ad[v][i]] == 0)
		{
			dfs(ad[v][i]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	iw.push_back({0, 0});
	while(n--)
	{
		int x;
		cin >> x;
		if(x == 1)
		{
			pair <int , int> t;
			cin >> t.first >> t.second;
			iw.push_back(t);
			for(int i = 1; i < iw.size() - 1 ; i++)
			{
				if((t.first > iw[i].first && t.first < iw[i].second) || (t.second > iw[i].first && t.second < iw[i].second) )
				{
					ad[iw.size() - 1].push_back(i);

				}
				if((iw[i].first > t.first && iw[i].first < t.second) || (iw[i].second < t.second && iw[i].second > t.first))
				{
					ad[i].push_back(iw.size() - 1);

				}
			}
		}
		else
		{
			cin >> a >> b;
			dfs(a);
			if(ok)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
			ok = 0;
			for(int i = 0; i < N; i ++)
				mark[i] = 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 110;
vector < pair <int , int> > iw;
vector < int > ad[N];
int a, b;
bool ok = 0;
bool mark[N];
void dfs(int v) {
	mark[v] = 1;
	if(v == b)
		ok = 1;
	for(int i = 0; i < ad[v].size(); i++)
	{
		if(mark[ad[v][i]] == 0)
		{
			dfs(ad[v][i]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	iw.push_back({0, 0});
	while(n--)
	{
		int x;
		cin >> x;
		if(x == 1)
		{
			pair <int , int> t;
			cin >> t.first >> t.second;
			iw.push_back(t);
			for(int i = 1; i < iw.size() - 1; i++)
			{
				if((t.first > iw[i].first && t.first < iw[i].second) ||(t.second > iw[i].first && t.second < iw[i].second))
				{
					ad[iw.size() - 1].push_back(i);
					ad[i].push_back(iw.size() - 1);
				}
			}
		}
		else
		{
			cin >> a >> b;
			dfs(a);
			if(ok)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
			ok = 0;
			for(int i = 0; i < N; i ++)
				mark[i] = 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 110;
vector < pair <int , int> > iw;
vector < int > ad[N];
int a, b;
bool ok = 0;
bool mark[N];
void dfs(int v) {
	mark[v] = 1;
	if(v == b)
		ok = 1;
	for(int i = 0; i < ad[v].size(); i++)
	{
		if(mark[ad[v][i]] == 0)
		{
			dfs(ad[v][i]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	while(n--)
	{
		int x;
		cin >> x;
		if(x == 1)
		{
			pair <int , int> t;
			cin >> t.first >> t.second;
			iw.push_back(t);
			for(int i = 0; i < iw.size() - 1; i++)
			{
				if((t.first > iw[i].first && t.first < iw[i].second) ||(t.second > iw[i].first && t.second < iw[i].second))
				{
					ad[iw.size() - 1].push_back(i);
					ad[i].push_back(iw.size() - 1);
				}
			}
		}
		else
		{
			cin >> a >> b;
			dfs(a);
			if(ok)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
			ok = 0;
			for(int i = 0; i < N; i ++)
				mark[i] = 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 110;
vector < pair <int , int> > iw;
vector < int > ad[N];
int a, b;
bool ok = 0;
bool mark[N];
void dfs(int v) {
	mark[v] = 1;
	if(v == b)
		ok = 1;
	for(int i = 0; i < ad[v].size(); i++)
	{
		if(mark[ad[v][i]] == 0)
		{
			dfs(ad[v][i]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	while(n--)
	{
		int x;
		cin >> x;
		if(x == 1)
		{
			pair <int , int> t;
			cin >> t.first >> t.second;
			iw.push_back(t);
			for(int i = 0; i < iw.size() - 1; i++)
			{
				if((t.first > iw[i].first && t.first < iw[i].second) ||(t.second > iw[i].first && t.second < iw[i].second))
				{
					ad[iw.size() - 1].push_back(i);
					ad[i].push_back(iw.size() - 1);
				}
			}
		}
		else
		{
			cin >> a >> b;
			a--;
			b--;
			dfs(a);
			if(ok)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
			ok = 0;
			for(int i = 0; i < N; i ++)
				mark[i] = 0;
		}
	}

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
bool ljd[123][123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<cntal;i++)
		if(ljd[qj][i]&&!dfsed[i])dfs_it(i);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((((C<A)&&(A<D))||((C<B)&&(B<D)))&&!(((C<A)&&(B<D))))||((((A<D)&&(D<B))||((A<C)&&(C<B)))&&!(((A<C)&&(D<B)))))
		{
			ljd[i][cntal-1]=true;
			ljd[cntal-1][i]=true;
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(--a);
	if(dfsed[--b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
bool ljd[123][123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<cntal;i++)
		if(ljd[qj][i]&&!dfsed[i])dfs_it(i);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((((C<A)&&(A<D))||((C<B)&&(B<D)))||((((C<A)&&(B<D)))))||((((A<D)&&(D<B))||((A<C)&&(C<B)))||((((A<C)&&(D<B))))))
		{
			bool a=(((C<A)&&(B<D))),b=(((A<C)&&(D<B)));
			if(!a)ljd[i][cntal-1]=true;
			if(!b)ljd[cntal-1][i]=true;
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(--a);
	if(dfsed[--b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
bool ljd[123][123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<cntal;i++)
		if(ljd[qj][i]&&!dfsed[i])dfs_it(i);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((((C<A)&&(A<D))||((C<B)&&(B<D)))/*&&!(((C<A)&&(B<D)))*/)||((((A<D)&&(D<B))||((A<C)&&(C<B)))/*&&!(((A<C)&&(D<B)))*/))
		{
			ljd[i][cntal-1]=true;
			ljd[cntal-1][i]=true;
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(--a);
	if(dfsed[--b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
vector<int> ljd[123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<ljd[qj].size();i++)
		if(!dfsed[ljd[qj][i]])dfs_it(ljd[qj][i]);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if((C<A&&A<D||C<B&&B<D)&&!(C<A&&B<D));
			ljd[i].push_back(cntal-1);
			ljd[cntal-1].push_back(i);
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(a);
	if(dfsed[b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
bool ljd[123][123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<cntal;i++)
		if(ljd[qj][i]&&!dfsed[i])dfs_it(i);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((C<A&&A<D)||(C<B&&B<D))&&!((C<A&&B<D)))
		{
			ljd[i][cntal-1]=true;
			ljd[cntal-1][i]=true;
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(--a);
	if(dfsed[--b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
bool ljd[123][123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<cntal;i++)
		if(ljd[qj][i]&&!dfsed[i])dfs_it(i);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((((C<A)&&(A<D))||((C<B)&&(B<D)))||((((C<A)&&(B<D)))))||((((A<D)&&(D<B))||((A<C)&&(C<B)))||((((A<C)&&(D<B))))))
		{
			bool a=(((C<A)&&(B<D))),b=(((A<C)&&(D<B)));
			if(!b)ljd[i][cntal-1]=true;
			if(!a)ljd[cntal-1][i]=true;
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(--a);
	if(dfsed[--b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
bool ljd[123][123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<cntal;i++)
		if(ljd[qj][i]&&!dfsed[i])dfs_it(i);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((((C<=A)&&(A<=D))||((C<=B)&&(B<=D)))&&!(((C<=A)&&(B<=D))))||((((A<=D)&&(D<=B))||((A<=C)&&(C<=B)))&&!(((A<=C)&&(D<=B)))))
		{
			ljd[i][cntal-1]=true;
			ljd[cntal-1][i]=true;
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(--a);
	if(dfsed[--b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
pair<int,int> qjs[123];
vector<int> ljd[123];
bool dfsed[123];
int n,cntal=0;
inline void dfs_it(int qj)
{
	dfsed[qj]=true;
	for(int i=0;i<ljd[qj].size();i++)
		if(!dfsed[ljd[qj][i]])dfs_it(ljd[qj][i]);
}

inline void _1()
{
	int x,y;
	scanf("%d %d",&x,&y);
	qjs[cntal++]=make_pair(x,y);
	#define A x
	#define B y
	for(int i=0;i<cntal-1;i++)
	{
		#define C qjs[i].first
		#define D qjs[i].second
		if(((C<A&&A<D)||(C<B&&B<D))&&!(C<A&&B<D))
		{
			ljd[i].push_back(cntal-1);
			ljd[cntal-1].push_back(i);
		}
	}
}

inline void _2()
{
	int a,b;
	scanf("%d %d",&a,&b);
	memset(dfsed,0,sizeof(dfsed));
	dfs_it(a);
	if(dfsed[b]==true)puts("YES");
	else puts("NO");
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int _12;
		scanf("%d",&_12);
		_12==1?_1():_2();
	}
	return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if (1==2&&(a1>a3&&a1<a4&&a2>=a4)||(a1<=a3&&a2>a3&&a2<a4)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
		else
		{
			long long aa, aaa;
			aa = a1;
			aaa = a2;
			a1 = a3;
			a2 = a4;
			a3 = aa;
			a4 = aaa;
			if ((a1 > a3 && a1 < a4 && a2 >= a4) || (a1 <= a3 && a2 > a3 && a2 < a4)) {
				arr2[i][size] = 1;
				arr2[size][i] = 1;
			}
		}
	}
}
bool search(long long a,long long b,long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		if (q.front() == b)
		{
			res = 1;
			break;
		}
		for (int i=0;i<105;i++)
		{
			if (arr2[q.front()][i]==1&&!(vis.find(i)!=vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == b)
				{
					res = 1;
					break;
				}

			}
		}
		if (q.front()==b)
		{
			res = 1;
			break;
		}
		if (res)break;
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{
			/*for (int i=0;i<20;i++)
			{
				for (int ii = 0; ii < 20; ii++)
				{
					cout << arr2[i][ii] << ' ';
				}
				cout << endl;
			}*/

			if ((bool)search(b - 1, c - 1, arr2))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1<=a3&&a2>a3&&a2<a4)||(a3<=a1&&a4>a1&&a4<a2)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
bool search(long long a,long long b,long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		if (q.front() == b)
		{
			res = 1;
			break;
		}
		for (int i=0;i<105;i++)
		{
			if (arr2[q.front()][i]==1&&!(vis.find(i)!=vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == b)
				{
					res = 1;
					break;
				}

			}
		}
		if (q.front()==b)
		{
			res = 1;
			break;
		}
		if (res)break;
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{

			if ((bool)search(b - 1, c - 1, arr2))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if (((a1<a4&&a1>a3)||(a2<a4&&a2>a3))||((a3<a2&&a3>a1)||(a4>a1&&a4<a2))){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
int search(long long a,long long b,long long arr2[][105],set<int>vis)
{
	vis.insert(a);
	if (a == b)return 1;
	bool r = 0;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
		{
			r = 1;
			break;
		}
	}
	if (r == 0)return 0;
	else
	{
		int res = 0;
		for (int i = 0; i < 105; i++)
		{
			if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
			{
				res=max( search(i, b, arr2, vis),res);
			}
		}
		return res;
	}

}
int main() {
	int n;
	cin >> n;
	long long a, b, c;
	inter arr[105];
	long long s = 0;
	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{
			set<int>vis;
			if ((bool)search(b - 1, c - 1, arr2, vis))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct point
{
	long long start, end;
};
vector <point>arr;
bool ch[105] = {};
void insert(long long a, long long b)
{
	point x;
	x.start = a;
	x.end = b;
	arr.push_back(x);
}
bool check(int a,int b)
{
	if (arr[a].start<arr[b].end && arr[a].start>arr[b].start)
		return 1;
	else if (arr[a].end > arr[b].start && arr[a].end < arr[b].end)
		return 1;
	else return 0;
}
bool dfs(int start ,int des)
{
	if (start == des)return 1;

		for (int i = 0; i < arr.size(); i++)
		{
			if (check(start, i)&&ch[i]==0)
			{
				ch[i] = 1;
				bool h;
				h= dfs(i, des);
				//cout << h<<endl;
				return h;

			}
		}

	return 0;
}
int main() {
	int n;
	cin >> n;
	long long  a, b, c;
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c);
		}
		else
		{
			b--;
			c--;
			ch[b] = 1;
			if (dfs(b, c))
			{
				cout << "YES";
			}
			else
			{
				cout << "NO";
			}
			cout << endl;
			for (int ii=0;ii<105;ii++)
			{
				ch[ii] = 0;
			}
		}
	}

	return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105], int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if (1 == 2 && (a1 > a3 && a1 < a4 && a2 >= a4) || (a1 <= a3 && a2 > a3 && a2 < a4)) {
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
		else
		{
			long long aa, aaa;
			aa = a1;
			aaa = a2;
			a1 = a3;
			a2 = a4;
			a3 = aa;
			a4 = aaa;
			if ((a1 > a3 && a1 < a4 && a2 >= a4) || (a1 <= a3 && a2 > a3 && a2 < a4)) {
				arr2[i][size] = 1;
				arr2[size][i] = 1;
			}
		}
	}
}
bool search(long long a, long long b, long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		if (q.front() == b)
		{
			res = 1;
			break;
		}
		for (int i = 0; i < 105; i++)
		{
			if (arr2[q.front()][i] == 1 && !(vis.find(i) != vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == b)
				{
					res = 1;
					break;
				}

			}
		}
		if (q.front() == b)
		{
			res = 1;
			break;
		}
		if (res)break;
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i = 0; i < n; i++)
	{
		cin >> a >> b >> c;
		if (a == 1)
		{
			insert(b, c, arr, arr2, s);
			s++;
		}
		else
		{
			/*for (int i=0;i<20;i++)
			{
				for (int ii = 0; ii < 20; ii++)
				{
					cout << arr2[i][ii] << ' ';
				}
				cout << endl;
			}*/
			if (b == c)cout << "YES";
			else {
				if ((bool)search(b - 1, c - 1, arr2))
					cout << "YES";
				else
					cout << "NO";
			}
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1<=a3&&a2>a3&&a2<a4)||(a3<=a1&&a4>a1&&a4<a2)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
bool search(long long a,long long b,long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[b][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		for (int i=0;i<105;i++)
		{
			if (arr2[q.front()][i]==1&&!(vis.find(i)!=vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == a)
				{
					res = 1;
					break;
				}

			}
		}
		if (res)break;
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{

			if ((bool)search(b - 1, c - 1, arr2))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1<=a3&&a2>a3&&a2<a4)||(a3<=a1&&a4>a1&&a4<a2)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
int search(long long a,long long b,long long arr2[][105],set<int>vis)
{
	vis.insert(a);
	if (a == b)return 1;
	bool r = 0;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
		{
			r = 1;
			break;
		}
	}

	if (r == 0)return 0;
	else
	{
		int res = 0;
		for (int i = 0; i < 105; i++)
		{
			if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
			{
				res=max( search(i, b, arr2, vis),res);
			}
		}
		return res;
	}

}
int main() {
	int n;
	cin >> n;
	long long a, b, c;
	set<int>vis;
	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{
			vis.clear();

			if ((bool)search(b - 1, c - 1, arr2, vis))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if (((a1<a4&&a1>a3)||(a2<a4&&a2>a3))||((a3<a2&&a3>a1)||(a4>a1&&a4<a2))){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
int search(long long a,long long b,long long arr2[][105],set<int>vis)
{
	vis.insert(a);
	if (a == b)return 1;
	bool r = 0;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
		{
			r = 1;
			break;
		}
	}

	if (r == 0)return 0;
	else
	{
		int res = 0;
		for (int i = 0; i < 105; i++)
		{
			if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
			{
				res=max( search(i, b, arr2, vis),res);
			}
		}
		return res;
	}

}
int main() {
	int n;
	cin >> n;
	long long a, b, c;
	set<int>vis;
	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{
			vis.clear();
			if ((bool)search(b - 1, c - 1, arr2, vis))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1<=a3&&a2>a3&&a2<a4)||(a3<a1&&a4>a1&&a4<=a2)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
bool search(long long a,long long b,long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		if (q.front() == b)
		{
			res = 1;
			break;
		}
		for (int i=0;i<105;i++)
		{
			if (arr2[q.front()][i]==1&&!(vis.find(i)!=vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == b)
				{
					res = 1;
					break;
				}

			}
		}
		if (q.front()==b)
		{
			res = 1;
			break;
		}
		if (res)break;
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{

			if ((bool)search(b - 1, c - 1, arr2))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1<=a3&&a2>a3&&a2<a4)||(a3<=a1&&a4>a1&&a4<a2)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
bool search(long long a,long long b,long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		for (int i=0;i<105;i++)
		{
			if (arr2[q.front()][i]==1&&!(vis.find(i)!=vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == b)
				{
					res = 1;
					break;
				}

			}
		}
		if (q.front()==b)
		{
			res = 1;
			break;
		}
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{

			if ((bool)search(b - 1, c - 1, arr2))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <vector>
#include <iostream>
#include <set>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][100],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1 < a3 && a1 < a4 && (a2 > a3 || a2 > a4 ))|| (a2 < a3 && a2 < a4 && (a1 > a3 || a1 > a4 ))||( a3 < a1 && a3 < a2 && (a4 > a1 || a4 > a2 ))|| (a4 < a1 && a4 < a2 &&( a3 > a1 || a3 > a2) )){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
	}
}
int search(long long a,long long b,long long arr2[][100],set<int>vis)
{
	vis.insert(a);
	if (a == b)return 1;
	bool r = 0;
	for (int i = 0; i < 100; i++)
	{
		if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
		{
			r = 1;
			break;
		}
	}
	if (r == 0)return 0;
	else
	{
		int res = 0;
		for (int i = 0; i < 100; i++)
		{
			if (arr2[a][i] == 1 && !(vis.find(i) != vis.end()))
			{
				res=max( search(i, b, arr2, vis),res);
			}
		}
		return res;
	}

}
int main() {
	int n;
	cin >> n;
	long long a, b, c;
	inter arr[100];
	long long s = 0;
	long long arr2[100][100] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{
			set<int>vis;
			if ((bool)search(b - 1, c - 1, arr2, vis))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct point
{
	long long start, end;
};
vector <point>arr;
bool ch[105] = {};
void insert(long long a, long long b)
{
	point x;
	x.start = a;
	x.end = b;
	arr.push_back(x);
}
bool check(int a,int b)
{
	if (arr[a].start<arr[b].end && arr[a].start>arr[b].start)
		return 1;
	else if (arr[a].end > arr[b].start && arr[a].end < arr[b].end)
		return 1;
	else return 0;
}
bool dfs(int start ,int des)
{
	if (start == des)return 1;

		for (int i = 0; i < arr.size(); i++)
		{
			if (check(start, i)&&ch[i]==0)
			{
				ch[i] = 1;
				bool h;
				if (dfs(i, des))return 1;
				//cout << h<<endl;

			}
		}

	return 0;
}
int main() {
	int n;
	cin >> n;
	long long  a, b, c;
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c);
		}
		else
		{
			b--;
			c--;
			ch[b] = 1;
			if (dfs(b, c))
			{
				cout << "YES";
			}
			else
			{
				cout << "NO";
			}
			cout << endl;
			for (int ii=0;ii<105;ii++)
			{
				ch[ii] = 0;
			}
		}
	}

	return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cmath>
#include  <math.h>
#include <algorithm>
using namespace std;
struct inter {
	long long start;
	long long end;
};
void insert(long long a, long long b, inter arr[], long long arr2[][105],int size)
{
	arr[size].start = a;
	arr[size].end = b;
	for (int i = 0; i < size; i++)
	{
		long long a1 = arr[size].start, a2 = arr[size].end, a3 = arr[i].start, a4 = arr[i].end;
		if ((a1>a3&&a1<a4&&a2>=a4)||(a1<=a3&&a2>a3&&a2<a4)){
			arr2[i][size] = 1;
			arr2[size][i] = 1;
		}
		else
		{
			long long aa, aaa;
			aa = a1;
			aaa = a2;
			a1 = a3;
			a2 = a4;
			a3 = aa;
			a4 = aaa;
			if ((a1 > a3 && a1 < a4 && a2 >= a4) || (a1 <= a3 && a2 > a3 && a2 < a4)) {
				arr2[i][size] = 1;
				arr2[size][i] = 1;
			}
		}
	}
}
bool search(long long a,long long b,long long arr2[][105])
{
	set<long long >vis;
	queue<long long >q;
	for (int i = 0; i < 105; i++)
	{
		if (arr2[a][i] == 1)
		{
			vis.insert(i);
			q.push(i);
		}
	}
	bool res = 0;
	while (!q.empty())
	{
		if (q.front() == b)
		{
			res = 1;
			break;
		}
		for (int i=0;i<105;i++)
		{
			if (arr2[q.front()][i]==1&&!(vis.find(i)!=vis.end()))
			{
				q.push(i);
				vis.insert(i);
				if (i == b)
				{
					res = 1;
					break;
				}

			}
		}
		if (q.front()==b)
		{
			res = 1;
			break;
		}
		if (res)break;
		q.pop();
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	long long a, b, c;

	inter arr[105];
	long long s = 0;

	long long arr2[105][105] = {};
	for (int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if (a==1)
		{
			insert(b, c,arr,arr2,s);
			s++;
		}
		else
		{
			/*for (int i=0;i<20;i++)
			{
				for (int ii = 0; ii < 20; ii++)
				{
					cout << arr2[i][ii] << ' ';
				}
				cout << endl;
			}*/

			if ((bool)search(b - 1, c - 1, arr2))
				cout << "YES";
			else
				cout << "NO";
			cout << endl;
		}
	}
	return 0;
}
/*
20
1 1208 1583
1 -258 729
1 -409 1201
1 194 1938
1 -958 1575
1 -1466 1752
2 1 2
2 1 2
2 6 5
1 -1870 1881
1 -2002 2749
1 -2002 2984
1 -2002 3293
2 2 4
2 8 10
2 9 6
1 -2002 3572
1 -2002 4175
1 -2002 4452
1 -2002 4605
*/


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;
bool visited[101];

bool dfs(int a, int b){
  ii A = graph[a];
  ii B = graph[b];

  visited[a] = true;

  if(a==b)
    return true;

  for(int i=1; i< graph.size(); i++){
    ii o = graph[i];
    if( !visited[i] &&
      (( o.first < A.first && A.first < o.second) ||
      ( o.first < A.second && A.second < o.second)) )
      return dfs( i , b );
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));
    for(int i=0; i<101; i++)
      visited[i] = false;

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q==1)
        graph.push_back(ii(a,b));
      else{
        cout << (dfs(a,b)?"YES":"NO") << endl;
        for(int i = 0; i<101; i++)
          visited[i] = false;
      }
    }

    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;

bool dfs(int a, int b){
  if(a==b)
    return true;
  ii A = graph[a];
  for(ii o : graph){
    if( ( o.first < A.first && A.first < o.second) ||
        ( o.first < A.second && A.second < o.second) )
      return dfs( a+1, b );
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q&1)
        graph.push_back(ii(a,b));
      else
        cout << (dfs(a,b)?"YES":"NO") << endl;
    }

    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;
bool visited[101];

bool dfs(int a, int b){
  ii A = graph[a];

  visited[a] = true;

  if(a==b)
    return true;

  for(int i=1; i< graph.size(); i++){
    ii o = graph[i];
    if( !visited[i] &&
      (( o.first < A.first && A.first < o.second) ||
      ( o.first < A.second && A.second < o.second)) )
      if(dfs( i , b ))
        return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));
    for(int i=0; i<101; i++)
      visited[i] = false;

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q==1)
        graph.push_back(ii(a,b));
      else{
        cout << (dfs(a,b)?"YES":"NO") << endl;
        for(int i = 0; i<101; i++)
          visited[i] = false;
      }
    }

    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;
bool visited[101];

bool dfs(int a, int b){
  ii A = graph[a];
  ii B = graph[b];

  visited[a] = true;

  if(a==b)
    return true;

  for(int i=1; i< graph.size(); i++){
    ii o = graph[i];
    if( !visited[i] &&
      (( o.first < A.first && A.first < o.second) ||
      ( o.first < A.second && A.second < o.second)) )
      if(dfs( i , b ))
        return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));
    for(int i=0; i<101; i++)
      visited[i] = false;

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q==1)
        graph.push_back(ii(a,b));
      else{
        cout << (dfs(a,b)?"YES":"NO") << endl;
        for(int i = 0; i<101; i++)
          visited[i] = false;
      }
    }

    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;
bool visited[101];

bool dfs(int a, int b){
  ii A = graph[a];
  ii B = graph[b];

  visited[a] = true;

  if(a==b )// ( ( B.first < A.first && A.first < B.second) ||
    return true;    //( B.first < A.second && A.second < B.second) ) )

  for(int i=0; i< graph.size(); i++){
    ii o = graph[i];
    if( !visited[i] && (( o.first < A.first && A.first < o.second) ||
        ( o.first < A.second && A.second < o.second)) )
      return dfs( i , b );
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));
    for(int i=0; i<100; i++)
      visited[i] = false;

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q==1)
        graph.push_back(ii(a,b));
      else{
        cout << (dfs(a,b)?"YES":"NO") << endl;
      }
    }

    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;

bool dfs(int a, int b){
  if(a>graph.size())
    return false;
  if(a==b)
    return true;
  ii A = graph[a];
  for(ii o : graph){
    if( ( o.first < A.first && A.first < o.second) ||
        ( o.first < A.second && A.second < o.second) )
      return dfs( a+1, b );
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q==1)
        graph.push_back(ii(a,b));
      else{
        cout << (dfs(a,b)?"YES":"NO") << endl;
      }
    }

    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define FIRST first
#define SECOND second.first
#define THIRD second.second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

vii graph;
bool visited[101];
bool dfs(int a, int b){
  ii A = graph[a];

  visited[a] = true;

  if(a==b)
    return true;

  for(int i=1; i< graph.size(); i++){
    ii o = graph[i];
    if( !visited[i] &&
      (( o.first < A.first && A.first < o.second) ||
      ( o.first < A.second && A.second < o.second)) )
      if(dfs( i , b ))
        return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    graph.push_back(ii(0,0));
    for(int i=0; i<101; i++)
      visited[i] = false;

    int n, a, b, q;
    scanf("%d", &n);
    while(n--){
      scanf("%d %d %d", &q, &a, &b);
      if(q==1)
        graph.push_back(ii(a,b));
      else{
        cout << (dfs(a,b)?"YES":"NO") << endl;
        for(int i = 0; i<101; i++)
          visited[i] = false;
      }
    }

    return 0;
}


#include <iostream>
#include <unordered_set>

using namespace std;

int n, q, a, b;
int nodes[101][3];
int next_node = 1;
int next_set = 0;
unordered_set<int> sets;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> q >> a >> b;
        if (q - 1) {
            cout << (nodes[a][2] == nodes[b][2] ? "YES" : "NO") << endl;
        } else {
            nodes[next_node][0] = a;
            nodes[next_node][1] = b;
            sets.clear();
            for (int j = 1; j < next_node; j++) {
                if (nodes[j][0] < a && a < nodes[j][1] || nodes[j][0] < b && b < nodes[j][1]) {
                    sets.insert(nodes[j][2]);
                }
            }
            if (sets.empty()) {
                nodes[next_node++][2] = next_set++;
            } else {
                int set = *sets.begin();
                if (sets.size() > 1) {
                    for (int j = 1; j < next_node; j++) {
                        if (sets.find(nodes[j][2]) != sets.end()) {
                            nodes[j][2] = set;
                        }
                    }
                }
                nodes[next_node++][2] = set;
            }
        }
    }
}


#include <iostream>
#include <queue>

using namespace std;

int n, q, a, b;
int nodes[101][2];
int next_node = 1;
bool graph[101][101] = { false };

bool isConnected(int s, int t) {
    queue<int> frontier;
    frontier.push(s);
    bool visited[101] = { false };
    while (!frontier.empty()) {
        int node = frontier.front();
        frontier.pop();
        if (node == t || graph[node][t]) {
            return true;
        }
        if (!visited[node]) {
            visited[node] = true;
            for (int i = 1; i < next_node; i++) {
                if (!visited[i] && graph[s][i]) {
                    if (graph[i][t]) {
                        return true;
                    }
                    frontier.push(i);
                }
            }
        }
    }
    return false;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> q >> a >> b;
        if (q - 1) {
            cout << (isConnected(a, b) ? "YES" : "NO") << endl;
        } else {
            nodes[next_node][0] = a;
            nodes[next_node][1] = b;
            for (int j = 1; j < next_node; j++) {
                graph[next_node][j] = nodes[j][0] < a && a < nodes[j][1] || nodes[j][0] < b && b < nodes[j][1];
                graph[j][next_node] = a < nodes[j][0] && nodes[j][0] < b || a < nodes[j][1] && nodes[j][1] < b;
            }
            next_node++;
        }
    }
}


#include <iostream>
#include <unordered_set>

using namespace std;

int n, q, a, b;
int nodes[101][2];
int next_node = 1;
bool graph[101][101] = { false };
bool visited[101] = { false };

bool isConnected(int s, int t) {
    if (s == t || graph[s][t]) {
        return true;
    } else if (visited[s]) {
        return false;
    }
    visited[s] = true;
    bool connected = false;
    for (int i = 1; !connected && i < next_node; i++) {
        if (graph[s][i]) {
            connected = isConnected(i, t);
            graph[s][t] = connected;
        }
    }
    visited[s] = false;
    return connected;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> q >> a >> b;
        if (q - 1) {
            cout << (isConnected(a, b) ? "YES" : "NO") << endl;
        } else {
            nodes[next_node][0] = a;
            nodes[next_node][1] = b;
            for (int j = 1; j < next_node; j++) {
                graph[next_node][j] = nodes[j][0] < a && a < nodes[j][1] || nodes[j][0] < b && b < nodes[j][1];
                graph[j][next_node] = a < nodes[j][0] && nodes[j][0] < b || a < nodes[j][1] && nodes[j][1] < b;
            }
            next_node++;
        }
    }
}


#include <iostream>
#include <unordered_set>

using namespace std;

int n, q, a, b;
int nodes[101][2];
int next_node = 1;
bool graph[101][101] = { false };
bool visited[101] = { false };

bool isConnected(int s, int t) {
    if (s == t || graph[s][t]) {
        return true;
    } else if (visited[s]) {
        return false;
    }
    visited[s] = true;
    bool connected = false;
    for (int i = 1; !connected && i < next_node; i++) {
        if (graph[s][i]) {
            connected = isConnected(i, t);
        }
    }
    visited[s] = false;
    return connected;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> q >> a >> b;
        if (q - 1) {
            cout << (isConnected(a, b) ? "YES" : "NO") << endl;
        } else {
            nodes[next_node][0] = a;
            nodes[next_node][1] = b;
            for (int j = 1; j < next_node; j++) {
                graph[next_node][j] = nodes[j][0] < a && a < nodes[j][1] || nodes[j][0] < b && b < nodes[j][1];
                graph[j][next_node] = a < nodes[j][0] && nodes[j][0] < b || a < nodes[j][1] && nodes[j][1] < b;
            }
            next_node++;
        }
    }
}


#include <iostream>
#include <queue>

using namespace std;

int n, q, a, b;
int nodes[101][2];
int next_node = 1;
bool graph[101][101] = { false };

bool isConnected(int s, int t) {
    queue<int> frontier;
    frontier.push(s);
    bool visited[101] = { false };
    while (!frontier.empty()) {
        int node = frontier.front();
        frontier.pop();
        if (node == t || graph[node][t]) {
            return true;
        }
        if (!visited[node]) {
            visited[node] = true;
            for (int i = 1; i < next_node; i++) {
                if (!visited[i] && graph[node][i]) {
                    if (graph[i][t]) {
                        return true;
                    }
                    frontier.push(i);
                }
            }
        }
    }
    return false;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> q >> a >> b;
        if (q - 1) {
            cout << (isConnected(a, b) ? "YES" : "NO") << endl;
        } else {
            nodes[next_node][0] = a;
            nodes[next_node][1] = b;
            for (int j = 1; j < next_node; j++) {
                graph[next_node][j] = nodes[j][0] < a && a < nodes[j][1] || nodes[j][0] < b && b < nodes[j][1];
                graph[j][next_node] = a < nodes[j][0] && nodes[j][0] < b || a < nodes[j][1] && nodes[j][1] < b;
            }
            next_node++;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll        long long
#define pb        push_back
#define mp        make_pair
#define R         return 0
#define ff        first
#define ss        second
#define sc1(a)    scanf("%d",&a)
#define sc2(a,b)  scanf("%d%d",&a,&b)
#define scl1(a)   scanf("%I64d",&a)
#define scl2(a,b) scanf("%I64d %I64d",&a,&b)
#define all(a)    a.begin(),a.end()
#define pii       pair<int,int>
#define pll       pair<long,long>
#define hi        puts("Hi..!")
#define MAX       1000000

vector<int> E[400];
map<int,int> edge;
map<int,int> ulta;

int main() {
   int n;
   sc1(n);
   vector<int> v;
   vector<pii> p;
   int k = 0;
   while(n--){
    int x;sc1(x);
    if(x == 1){
      int a,b;
      sc2(a,b);
      v.pb(a);v.pb(b);
      p.pb(mp(a,b));
      if(!edge[a]){
        edge[a] = ++k;
        ulta[k-1] = a;
      }
      if(!edge[b]){
        edge[b] = ++k;
        ulta[k-1] = b;
      }
      E[edge[a]].pb(edge[b]);
      E[edge[b]].pb(edge[a]);
    }
    else{
      int a,b;
      sc2(a,b);
      int x1,y1,x2,y2;
      a--;b--;
      x1 = p[a].ff;y1 = p[a].ss;
      x2 = p[b].ff;y2 = p[b].ss;
      bool paisi = false;
      for(auto &i : v){
        if(v[i] >= x1 && v[i] <= y1){
          int u = v[i];
          for(int i = 0;i < E[u].size();i++){
            int v = E[u][i];
            int keep = ulta[v];
            if(keep > x2 && keep < y2){
              puts("YES");
              paisi = true;
              break;
            }
          }

        }
        if(paisi) break;
      }
      if(!paisi) puts("NO");
    }
   }

   R;
}


#include <bits/stdc++.h>
using namespace std;
#define ll        long long
#define pb        push_back
#define mp        make_pair
#define R         return 0
#define ff        first
#define ss        second
#define sc1(a)    scanf("%d",&a)
#define sc2(a,b)  scanf("%d%d",&a,&b)
#define scl1(a)   scanf("%I64d",&a)
#define scl2(a,b) scanf("%I64d %I64d",&a,&b)
#define all(a)    a.begin(),a.end()
#define pii       pair<int,int>
#define pll       pair<long,long>
#define hi        puts("Hi..!")
#define MAX       100000
vector <int> E[MAX];
int visit[MAX];
bool flag;
void dfs(int u,int dst)
{
  //cout << u <<" " << dst << endl;
  if(u == dst) {
     flag = true;
  }
  visit[u] = 1;
  for(int i = 0;i < E[u].size();i++){
    int v = E[u][i];
    if(!visit[v]) dfs(v,dst);
  }
}
int main() {
   int n;
   sc1(n);
   map<pii,int> node;
   vector<pii> v;
   int k = 0;
   for(int i = 1;i <= n;i++){
    int q;cin >> q;
    if(q == 1){
    int x,y;
    sc2(x,y);
    if(!node[mp(x,y)]){
      node[mp(x,y)] = ++k;
    }
    v.pb(mp(x,y));
    for(int j = 0;j < v.size();j++){
      pii tom = v[j];
      if(x == tom.ff && y == tom.ss) continue;
      if((x > tom.ff && x < tom.ss) ||(y > tom.ff && y < tom.ss)){
        int a,b;
        a = node[mp(x,y)];
        b = node[mp(tom.ff,tom.ss)];
        E[a].pb(b);
        E[b].pb(a);
      }
    }
    }
    else{
      int x,y;cin >> x >> y;
      int a,b;
      x--;y--;
      a = node[mp(v[x].ff,v[x].ss)];
      b = node[mp(v[y].ff,v[y].ss)];
   // cout << a <<" " << b << endl;
      memset(visit,0,sizeof visit);
       flag = false;dfs(a,b);
      if(flag) puts("YES");
      else puts("NO");
    }

   }
   R;
}


#include <bits/stdc++.h>
using namespace std;
#define ll        long long
#define pb        push_back
#define mp        make_pair
#define R         return 0
#define ff        first
#define ss        second
#define sc1(a)    scanf("%d",&a)
#define sc2(a,b)  scanf("%d%d",&a,&b)
#define scl1(a)   scanf("%I64d",&a)
#define scl2(a,b) scanf("%I64d %I64d",&a,&b)
#define all(a)    a.begin(),a.end()
#define pii       pair<int,int>
#define pll       pair<long,long>
#define hi        puts("Hi..!")
#define MAX       100000
vector <int> E[MAX];
int visit[MAX];
bool flag;
void dfs(int u,int dst)
{
  //cout << u <<" " << dst << endl;
  if(u == dst) {
     flag = true;
  }
  visit[u] = 1;
  for(int i = 0;i < E[u].size();i++){
    int v = E[u][i];
    if(!visit[v]) dfs(v,dst);
  }
}
int main() {
   int n;
   sc1(n);
   map<pii,int> node;
   vector<pii> v;
   int k = 0;
   for(int i = 1;i <= n;i++){
    int q;cin >> q;
    if(q == 1){
    int x,y;
    sc2(x,y);
    if(!node[mp(x,y)]){
      node[mp(x,y)] = ++k;
    }
    v.pb(mp(x,y));
    for(int j = 0;j < v.size();j++){
      pii tom = v[j];
      if(x == tom.ff && y == tom.ss) continue;
      if((x >= tom.ff && x < tom.ss && y > tom.ss) ||(y > tom.ff && y <= tom.ss && x < tom.ff)){

        int a,b;
        a = node[mp(x,y)];
        b = node[mp(tom.ff,tom.ss)];
        E[a].pb(b);
        E[b].pb(a);
      }
    }
    }
    else{
      int x,y;cin >> x >> y;
      int a,b;
      x--;y--;
      a = node[mp(v[x].ff,v[x].ss)];
      b = node[mp(v[y].ff,v[y].ss)];
   // cout << a <<" " << b << endl;
      memset(visit,0,sizeof visit);
       flag = false;dfs(a,b);
      if(flag) puts("YES");
      else puts("NO");
    }

   }
   R;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <stack>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int dp[4][20000];

int main() {
    string s;
    cin >> s;
    int n = (int)s.size();

    set<string> ans;

    dp[2][n] = dp[3][n] = 1;

    for (int i = n - 2; i >= 5; i--) {
    	if (dp[3][i + 2] || (dp[2][i + 2] && s.substr(i, 2) != s.substr(i + 2, 2))) {
    		dp[2][i] = 1;
    		ans.insert(s.substr(i, 2));
    	}

    	if (dp[2][i + 3] || (dp[3][i + 3] && s.substr(i, 3) != s.substr(i + 3, 3))) {
    		dp[3][i] = 1;
    		ans.insert(s.substr(i, 3));
    	}
    }

    cout << (int)ans.size() << endl;
    for (auto suffix: ans) {
    	cout << suffix << endl;
    }
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <stack>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

set<string> ans;
bool visited[50000];

void dfs(string str, set<string> suffixes) {
	int n = (int)str.size();
	visited[n] = true;

	for (int d = 2; d <= 3; d++) {
		int l = n - d;

		if (l >= 5 && !visited[l]) {
			string root = str.substr(0, l);
			string suffix = str.substr(l, d);

			if (suffixes.find(suffix) == suffixes.end()) {
				suffixes.insert(suffix);
				ans.insert(suffix);
				dfs(root, suffixes);
				suffixes.erase(suffix);
			}
		}
	}
}

int main() {
    string s;
    cin >> s;

    if ((int)s.size() < 7) {
    	cout << 0;
    	return 0;
    }

    set<string> suffixes;
    dfs(s, suffixes);

    cout << (int)ans.size() << endl;
    for (auto suffix: ans) {
    	cout << suffix << endl;
    }
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <stack>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

set<string> ans;
bool visited[50000];

void dfs(string str, set<string> suffixes) {
	int n = (int)str.size();
	visited[n] = true;

	for (int d = 2; d <= 3; d++) {
		int l = n - d;

		if (l < 5) continue;

		string root = str.substr(0, l);
		string suffix = str.substr(l, d);

		if (suffixes.find(suffix) == suffixes.end()) {
			ans.insert(suffix);

			if (!visited[l]) {
				suffixes.insert(suffix);
				dfs(root, suffixes);
				suffixes.erase(suffix);
			}
		}
	}
}

int main() {
    string s;
    cin >> s;

    set<string> suffixes;
    dfs(s, suffixes);

    cout << (int)ans.size() << endl;
    for (auto suffix: ans) {
    	cout << suffix << endl;
    }
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <stack>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

set<string> ans;
bool visited[5000];

void dfs(string str, set<string> suffixes) {
	int n = (int)str.size();
	visited[n] = true;

	for (int d = 2; d <= 3; d++) {
		int l = n - d;

		if (l >= 5 && !visited[l]) {
			string root = str.substr(0, l);
			string suffix = str.substr(l, d);

			if (suffixes.find(suffix) != suffixes.end()) {
				suffixes.insert(suffix);
				ans.insert(suffix);
				dfs(root, suffixes);
				suffixes.erase(suffix);
			}
		}
	}
}

int main() {
    string s;
    cin >> s;

    if ((int)s.size() < 7) {
    	cout << 0;
    	return 0;
    }

    set<string> suffixes;
    dfs(s, suffixes);

    cout << ans.size() << endl;
    for (auto suffix: ans) {
    	cout << suffix << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 1000000007
#define mx 1e18
#define pb push_back
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pii pair<int,int>
#define ff first
#define ss second

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

	string s;
	cin>>s;

	string tmp ="";

	int n = s.length();

	if(n==5)
	{
		cout<<0<<endl;
		return 0;
	}

	for(int i=5;i<n;i++)
		tmp.pb(s[i]);

	reverse(tmp.begin(),tmp.end());

	n = tmp.length();

	// cout<<n<<endl;

	if(n==1)
	{
		cout<<0<<endl;
		return 0;
	}

	bool dp2[n+1],dp3[n+1];
	for(int i=0;i<=n;i++)
	{
		dp2[i]=false;
		dp3[i]=false;
	}

	vector<string>finalans;

	if(n>=2)
	{
		dp2[1]=true;
		finalans.pb(tmp.substr(0,2));
	}
	if(n>=3)
	{
		finalans.pb(tmp.substr(0,3));
		dp3[2]=true;
	}
	if(n>=4)
	{
		string a = tmp.substr(0,2);
		string b = tmp.substr(2,2);

		if(a!=b)
			dp2[3]=true;

		finalans.pb(b);
	}
	if(n>=5)
	{
		dp2[4]=true;
		dp3[4]=true;

		finalans.pb(tmp.substr(2,3));
		finalans.pb(tmp.substr(3,2));
	}

	for(int i=5;i<n;i++)
	{
		string a = tmp.substr(i-3,2);
		string b = tmp.substr(i-1,2);

		if(dp3[i-2] ||(dp2[i-2] && (a!=b)))
		{
			dp2[i]=true;
			finalans.pb(b);
		}

		a = tmp.substr(i-5,3);
		b = tmp.substr(i-2,3);

		if(dp2[i-3] || (dp3[i-3] && (a!=b)))
		{
			dp3[i]=true;
			finalans.pb(b);
		}
	}

	for(int i=0;i<finalans.size();i++)
	{
		reverse(finalans[i].begin() , finalans[i].end());
	}
	sort(finalans.begin() ,finalans.end());

	// cout<<finalans.size()<<endl;

	vector<string>ff;
	ff.pb(finalans[0]);

	for(int i=1;i<finalans.size();i++)
	{
		if(finalans[i]!=finalans[i-1])
		{
			ff.pb(finalans[i]);
		}
	}

	cout<<ff.size()<<endl;

	for(int i=0;i<ff.size();i++)
	{
		cout<<ff[i]<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 1000000007
#define mx 1e18
#define pb push_back
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pii pair<int,int>
#define ff first
#define ss second

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

	string s;
	cin>>s;

	string tmp ="";

	int n = s.length();

	if(n==5)
	{
		cout<<0<<endl;
		return 0;
	}

	for(int i=5;i<n;i++)
		tmp.pb(s[i]);

	reverse(tmp.begin(),tmp.end());

	n = tmp.length();

	// cout<<n<<endl;

	if(n==1)
	{
		cout<<0<<endl;
		return 0;
	}

	bool dp2[n+1],dp3[n+1];
	for(int i=0;i<=n;i++)
	{
		dp2[i]=false;
		dp3[i]=false;
	}

	vector<string>finalans;

	if(n>=2)
	{
		dp2[1]=true;
		finalans.pb(tmp.substr(0,2));
	}
	if(n>=3)
	{
		finalans.pb(tmp.substr(0,3));
		dp3[2]=true;
	}

	if(n>=4)
	{
		string a = tmp.substr(0,2);
		string b = tmp.substr(2,2);

		if(a!=b)
			dp2[3]=true;

		finalans.pb(b);
	}

	if(n>=6)
	{
		string a = tmp.substr(0,3);
		string b = tmp.substr(3,3);

		if(a!=b)
			dp2[5]=true;

		finalans.pb(b);
	}

	for(int i=6;i<n;i++)
	{
		string a = tmp.substr(i-3,2);
		string b = tmp.substr(i-1,2);

		if(dp3[i-2] ||(dp2[i-2] && (a!=b)))
		{
			dp2[i]=true;
			finalans.pb(b);
		}

		a = tmp.substr(i-5,3);
		b = tmp.substr(i-2,3);

		if(dp2[i-3] || (dp3[i-3] && (a!=b)))
		{
			dp3[i]=true;
			finalans.pb(b);
		}
	}

	for(int i=0;i<finalans.size();i++)
	{
		reverse(finalans[i].begin() , finalans[i].end());
	}
	sort(finalans.begin() ,finalans.end());

	vector<string>ff;
	ff.pb(finalans[0]);

	for(int i=1;i<finalans.size();i++)
	{
		if(finalans[i]!=finalans[i-1])
		{
			ff.pb(finalans[i]);
		}
	}

	cout<<ff.size()<<endl;

	for(int i=0;i<ff.size();i++)
	{
		cout<<ff[i]<<endl;
	}

	return 0;
}


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

typedef long long lint;
typedef pair<int, int> ii;

int MOD = 1e9 + 7;
int INF = 0x3f3f3f3f;
// ll INF = 1e18;

string s;

vector<string> out;

int n, v[1005][2]={};

int same(int ux, int uy, int vx, int vy){
	if(uy - vy) return 0;
	for(int i=0;i<uy;i++) if(s[ux+i] - s[vx+i]) return 0;
	return 1;
}

void dfs(int ux, int uy){
	if(ux + uy > n) return;
	if(v[ux][uy-2]) return;
	v[ux][uy-2] = 1;
	dfs(ux + uy, 2);
	dfs(ux + uy, 3);
	string tmp; for(int i=0;i<uy;i++) tmp.push_back(s[ux+i]);
	reverse(tmp.begin(), tmp.end());
	out.push_back(tmp);
}

int solve(){
	cin >> s;
	reverse(s.begin(), s.end());
	n = s.size() - 5;
	if(n <= 1) return cout << 0 << endl, 0;
	dfs(0, 2); dfs(0, 3);
	sort(out.begin(), out.end());
	out.resize(unique(out.begin(), out.end()) - out.begin());
	cout << out.size() << endl;
	for(int i=0;i<out.size();i++) cout << out[i] << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


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

typedef long long lint;
typedef pair<int, int> ii;

int MOD = 1e9 + 7;
int INF = 0x3f3f3f3f;
// ll INF = 1e18;

string s;

vector<string> out;

int n, v[10005][2]={};

int same(int ux, int uy, int vx, int vy){
	if(uy - vy) return 0;
	for(int i=0;i<uy;i++) if(s[ux+i] - s[vx+i]) return 0;
	return 1;
}

void dfs(int ux, int uy){
	if(ux + uy > n) return;
	if(v[ux][uy-2]) return;
	v[ux][uy-2] = 1;
	if(!same(ux, uy, ux+uy, 2)) dfs(ux + uy, 2);
	if(!same(ux, uy, ux+uy, 3)) dfs(ux + uy, 3);
	string tmp; for(int i=0;i<uy;i++) tmp.push_back(s[ux+i]);
	reverse(tmp.begin(), tmp.end());
	out.push_back(tmp);
}

int solve(){
	cin >> s;
	reverse(s.begin(), s.end());
	n = s.size() - 5;
	if(n <= 1) return cout << 0 << endl, 0;
	dfs(0, 2); dfs(0, 3);
	sort(out.begin(), out.end());
	out.resize(unique(out.begin(), out.end()) - out.begin());
	cout << out.size() << endl;
	for(int i=0;i<out.size();i++) cout << out[i] << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}