#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

bool dfs(int here, int color)
{
	visited[here] = true;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
	return true;
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];

		if (!visited[there])
		{
			if (!dfs(there, colors[adj[root][i]]))
				return false;
		}
	}
	return true;
}

int solve()
{
	set<int> check;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				check.insert(here);
				check.insert(there);
			}
		}

	if (check.empty())
		return 1;
	for each (auto it in check)
		if (process(it))
			return it + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	adj = VVI(n); colors = VI(n);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		--u; --v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	REP(i, 0, n)
		cin >> colors[i];

	int ans = solve();
	if (ans < 0)
		cout << "NO\n";
	else
		cout << "YES\n" << ans << endl;

	return 0;
}


#define debug 0
#define _CRT_SECURE_NO_WARNINGS
#define read scanf
#define ii "%d",&
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int n;
vector <int> v[100001];
int c[100001];

bool u[100001] = { 0 };
bool u2[100001] = { 0 };

bool check(int vs, int col) {
	bool ok = 1;
	u[vs] = 1;

	for (int i = 0; i < v[vs].size(); i++)
		if (!u[v[vs][i]]) {
			if (col != c[v[vs][i]])
				return false;
			else
				ok = ok && check(v[vs][i], col);
		}

	return ok;
}

int main() {
	if (debug) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
	int i;

	cin >> n;
	for (i = 0; i < n - 1; i++) {
		int p, q;
		read(ii p); read(ii q);
		p--; q--;
		v[p].push_back(q);
		v[q].push_back(p);
	}

	for (i = 0; i < n; i++)
		read(ii c[i]);

	int l1 = -1, l2;
	for (i = 0; l1 == -1 && i < n; i++)
		for (int j = 0; l1 == -1 && j < v[i].size(); j++)
			if (c[i] != c[v[i][j]]) {
				l1 = i;
				l2 = v[i][j];
			}

	if (l1 == -1) {
		cout << "YES\n1";
		return 0;
	}

	bool bad = 0;
	for (int i = 0; !bad && i < v[l1].size(); i++)
		if (!check(v[l1][i], c[v[l1][i]]))
			bad = 1;

	if (!bad) {
		cout << "YES\n";
		cout << l1 + 1;
		return 0;
	}
	else {
		bad = 0;
		for (int i = 0; !bad && i < v[l2].size(); i++)
			if (!check(v[l2][i], c[v[l2][i]]))
				bad = 1;
	}
	if (!bad) {
		cout << "YES\n";
		cout << l2 + 1;
		return 0;
	}
	else
		cout << "NO";

	return 0;
}


#define debug 0
#define _CRT_SECURE_NO_WARNINGS
#define read scanf
#define ii "%d",&
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int n;
vector <int> v[100001];
int c[100001];

bool u[100001] = { 0 };

bool check(int vs, int col) {
	bool ok = 1;
	u[vs] = 1;

	for (int i = 0; i < v[vs].size(); i++)
		if (!u[v[vs][i]]) {
			if (col != c[v[vs][i]])
				return false;
			else
				ok = ok && check(v[vs][i], col);
		}

	return ok;
}

int main() {
	if (debug) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
	int i;

	cin >> n;
	for (i = 0; i < n - 1; i++) {
		int p, q;
		read(ii p); read(ii q);
		p--; q--;
		v[p].push_back(q);
		v[q].push_back(p);
	}

	for (i = 0; i < n; i++)
		read(ii c[i]);

	int l1 = -1, l2;
	for (i = 0; l1 == -1 && i < n; i++)
		for (int j = 0; l1 == -1 && j < v[i].size(); j++)
			if (c[i] != c[v[i][j]]) {
				l1 = i;
				l2 = v[i][j];
			}

	if (l1 == -1) {
		cout << "YES\n1";
		return 0;
	}

	bool bad = 0;
	for (int i = 0; !bad && i < v[l1].size(); i++) {
		u[l1] = 1;
		if (!check(v[l1][i], c[v[l1][i]]))
			bad = 1;
	}

	if (!bad) {
		cout << "YES\n";
		cout << l1 + 1;
		return 0;
	}
	else {
		bad = 0;
		for (int i = 0; i < 100001; i++)
			u[i] = 0;
		u[l2] = 1;
		for (int i = 0; !bad && i < v[l2].size(); i++)
			if (!check(v[l2][i], c[v[l2][i]]))
				bad = 1;
	}
	if (!bad) {
		cout << "YES\n";
		cout << l2 + 1;
		return 0;
	}
	else
		cout << "NO";

	return 0;
}


#define debug 0
#define _CRT_SECURE_NO_WARNINGS
#define read scanf
#define ii "%d",&
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int n;
vector <int> v[100001];
int c[100001];

bool u[100001] = { 0 };
bool u2[100001] = { 0 };

bool check(int vs, int col) {
	bool ok = 1;
	u[vs] = 1;

	for (int i = 0; i < v[vs].size(); i++)
		if (!u[v[vs][i]]) {
			if (col != c[v[vs][i]])
				return false;
			else
				ok = ok && check(v[vs][i], col);
		}

	return ok;
}

int main() {
	if (debug) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
	int i;

	cin >> n;
	for (i = 0; i < n - 1; i++) {
		int p, q;
		read(ii p); read(ii q);
		p--; q--;
		v[p].push_back(q);
		v[q].push_back(p);
	}

	for (i = 0; i < n; i++)
		read(ii c[i]);

	int l1 = -1, l2;
	for (i = 0; l1 == -1 && i < n; i++)
		for (int j = 0; l1 == -1 && j < v[i].size(); j++)
			if (c[i] != c[v[i][j]]) {
				l1 = i;
				l2 = v[i][j];
			}

	bool bad = 0;
	for (int i = 0; !bad && i < v[l1].size(); i++)
		if (!check(v[l1][i], c[v[l1][i]]))
			bad = 1;

	if (!bad) {
		cout << "YES\n";
		cout << l1 + 1;
		return 0;
	}
	else {
		bad = 0;
		for (int i = 0; !bad && i < v[l2].size(); i++)
			if (!check(v[l2][i], c[v[l2][i]]))
				bad = 1;
	}
	if (!bad) {
		cout << "YES\n";
		cout << l2 + 1;
		return 0;
	}
	else
		cout << "NO";

	return 0;
}


#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define td third
#define X first
#define Y second

typedef pair<long long ,long long > pt;

double eps = 1e-7;
long long  INF = 1e9;

int n;

vector<int> used(n);
vector<vector<int>> g(n);
vector<int> color(n);

int ans = -1;
bool bans = true;

void dfs(int t)
{
    used[t] = 1;

    for (int i = 0; i < g[t].size(); i++)
    {
        int to = g[t][i];
        //cout << t + 1 << " " << to + 1 << " " << ans + 1 << endl;
        //cout << color[t] << " " << color[to] << endl;
        if (!used[to])
        {
            if (color[to] != color[t] && ans == -1)
            {
                map<int, int> clrs;
                for (int i = 0; i < g[t].size(); i++)
                {
                    clrs[color[g[t][i]]]++;
                }

                int cnt = 0;
                for (auto it = clrs.begin(); it != clrs.end(); it++)
                {
                    cnt++;
                    if (it->second >= 2 && it->first != color[t])
                        ans = t;
                }
                if (cnt >= 2)
                    ans = t;

                if (ans != t)
                    ans = to;
            }
            else
            {
                if (ans != -1 && t != ans && color[to] != color[t] )
                {
                    //cout << t + 1 << " " << to + 1 << "BAD " << endl;
                    bans = false;
                }
            }

            dfs(to);
        }
    }
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;

    used = vector<int>(n);
    g = vector<vector<int>>(n);
    color = vector<int>(n);

    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;

        a--, b--;

        g[a].pb(b);
        g[b].pb(a);
    }

    for (int i = 0; i < n; i++)
    {
        cin >> color[i];
    }

    int start = 0;

    for (int i = 0; i < n; i++)
    {
        if (g[i].size() == 1)
        {
            start = i;
            break;
        }
    }

    //cout << start << endl;
    dfs(start);

    //cout << ans + 1 << endl;
    if (bans)
    {
        cout << "YES" << endl;
        if (ans == -1)
            cout << 1;
        else
            cout << ans + 1;
    }
    else
    {
        cout << "NO";
    }
}


#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define td third
#define X first
#define Y second

typedef pair<long long ,long long > pt;

double eps = 1e-7;
long long  INF = 1e9;

int n;

vector<int> used(n);
vector<vector<int>> g(n);
vector<int> color(n);

int ans = -1;
bool bans = true;

void dfs(int t)
{
    used[t] = 1;

    for (int i = 0; i < g[t].size(); i++)
    {
        int to = g[t][i];
        //cout << t + 1 << " " << to + 1 << " " << ans + 1 << endl;
        //cout << color[t] << " " << color[to] << endl;
        if (!used[to])
        {
            if (color[to] != color[t] && ans == -1)
            {
                map<int, int> clrs;
                for (int i = 0; i < g[t].size(); i++)
                {
                    clrs[color[g[t][i]]]++;
                }

                clrs[color[t]]++;

                int cnt = clrs.size();

                if (cnt == 2)
                {
                    for (auto it = clrs.begin(); it != clrs.end(); it++)
                    {
                        if (it->second >= 2 && it->first != color[t])
                            ans = t;
                    }
                }
                else
                {
                    ans = t;
                }

                if (ans != t)
                    ans = to;
            }
            else
            {
                if (ans != -1 && t != ans && color[to] != color[t] )
                {
                    //cout << t + 1 << " " << to + 1 << "BAD " << endl;
                    bans = false;
                }
            }

            dfs(to);
        }
    }
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;

    used = vector<int>(n);
    g = vector<vector<int>>(n);
    color = vector<int>(n);

    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;

        a--, b--;

        g[a].pb(b);
        g[b].pb(a);
    }

    for (int i = 0; i < n; i++)
    {
        cin >> color[i];
    }

    int start = 0;

    for (int i = 0; i < n; i++)
    {
        if (g[i].size() == 1)
        {
            start = i;
            break;
        }
    }

    //cout << start << endl;
    dfs(start);

    //cout << ans + 1 << endl;
    if (bans)
    {
        cout << "YES" << endl;
        if (ans == -1)
            cout << 1;
        else
            cout << ans + 1;
    }
    else
    {
        cout << "NO";
    }
}


#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define td third
#define X first
#define Y second

typedef pair<long long ,long long > pt;

double eps = 1e-7;
long long  INF = 1e9;

int n;

vector<int> used(n);
vector<vector<int>> g(n);
vector<int> color(n);

int ans = -1;
bool bans = true;

void dfs(int t)
{
    used[t] = 1;

    for (int i = 0; i < g[t].size(); i++)
    {
        int to = g[t][i];
        //cout << t + 1 << " " << to + 1 << " " << ans + 1 << endl;
        //cout << color[t] << " " << color[to] << endl;
        if (!used[to])
        {
            if (color[to] != color[t] && ans == -1)
            {
                map<int, int> clrs;
                for (int i = 0; i < g[t].size(); i++)
                {
                    clrs[color[g[t][i]]]++;
                }

                for (auto it = clrs.begin(); it != clrs.end(); it++)
                {
                    if (it->second >= 2 && it->first != color[t])
                        ans = t;
                }
                if (ans != t)
                    ans = to;
            }
            else
            {
                if (ans != -1 && t != ans && color[to] != color[t] )
                {
                    //cout << t + 1 << " " << to + 1 << "BAD " << endl;
                    bans = false;
                }
            }

            dfs(to);
        }
    }
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;

    used = vector<int>(n);
    g = vector<vector<int>>(n);
    color = vector<int>(n);

    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;

        a--, b--;

        g[a].pb(b);
        g[b].pb(a);
    }

    for (int i = 0; i < n; i++)
    {
        cin >> color[i];
    }

    int start = 0;

    for (int i = 0; i < n; i++)
    {
        if (g[i].size() == 1)
        {
            start = i;
            break;
        }
    }

    //cout << start << endl;
    dfs(start);

    //cout << ans + 1 << endl;
    if (bans)
    {
        cout << "YES" << endl;
        if (ans == -1)
            cout << 1;
        else
            cout << ans + 1;
    }
    else
    {
        cout << "NO";
    }
}


#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define td third
#define X first
#define Y second

typedef pair<long long ,long long > pt;

double eps = 1e-7;
long long  INF = 1e9;

int n;

vector<int> used(n);
vector<vector<int>> g(n);
vector<int> color(n);

int ans = -1;
bool bans = true;

void dfs(int t)
{
    used[t] = 1;

    for (int i = 0; i < g[t].size(); i++)
    {
        int to = g[t][i];
        //cout << t + 1 << " " << to + 1 << " " << ans + 1 << endl;
        //cout << color[t] << " " << color[to] << endl;
        if (!used[to])
        {
            if (color[to] != color[t] && ans == -1)
            {
                map<int, int> clrs;
                for (int i = 0; i < g[t].size(); i++)
                {
                    clrs[color[g[t][i]]]++;
                }

                for (auto it = clrs.begin(); it != clrs.end(); it++)
                {
                    if (it->second >= 2 && it->first != color[t])
                        ans = t;
                }
                if (ans != t)
                    ans = to;
            }
            else
            {

                if (ans != -1 && t != ans)
                {
                    bans = false;
                }
            }

            dfs(to);
        }
    }
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;

    used = vector<int>(n);
    g = vector<vector<int>>(n);
    color = vector<int>(n);

    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;

        a--, b--;

        g[a].pb(b);
        g[b].pb(a);
    }

    for (int i = 0; i < n; i++)
    {
        cin >> color[i];
    }

    int start = 0;

    for (int i = 0; i < n; i++)
    {
        if (g[i].size() == 1)
        {
            start = i;
            break;
        }
    }

    dfs(start);

    //cout << ans + 1 << endl;
    if (bans)
    {
        cout << "YES" << endl;
        if (ans == -1)
            cout << 1;
        else
            cout << ans + 1;
    }
    else
    {
        cout << "NO";
    }
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
#include<limits.h>
using namespace std;
int arr[200010];
vector<int> G[200010];

struct edge {
	int u, v;
	edge() {};
	edge(int a, int b) {
		u = a;
		v = b;
	}
};
vector<edge> elist;
pair<int, int> temp[200010];
int color[200010];
int check[200010];
int main() {
//	freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		temp[i].first = u;
		temp[i].second = v;
	}
	for (int i = 1; i <= n; i++) {
		cin >> color[i];
	}

	int esize = 0;
	for (int i = 1; i < n; i++) {
		int u = temp[i].first;
		int v = temp[i].second;
		if (color[u] != color[v]) {
			elist.push_back(edge(u, v));
			esize++;
			check[u]++;
			check[v]++;
		}
	}
	int flag = 0;
	for (int i = 1; i <= n; i++) {
		if (check[i] == esize) {
			cout << "YES" << endl;
			flag = 1;
			cout << i << endl;
		}
	}
	if(flag ==0)
	{
		cout << "NO" << endl;
	}
	return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
#include<limits.h>
using namespace std;
int arr[200010];
vector<int> G[200010];

struct edge {
	int u, v;
	edge() {};
	edge(int a, int b) {
		u = a;
		v = b;
	}
};
vector<edge> elist;
pair<int, int> temp[200010];
int color[200010];
int check[200010];
int main() {

//	freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		temp[i].first = u;
		temp[i].second = v;
	}
	for (int i = 1; i <= n; i++) {
		cin >> color[i];
	}
	int esize = 0;
	for (int i = 1; i < n; i++) {
		int u = temp[i].first;
		int v = temp[i].second;
		if (color[u] != color[v]) {
			elist.push_back(edge(u, v));
			esize++;
			check[u]++;
			check[v]++;
		}
	}
	int flag = 0;
	for (int i = 1; i < n; i++) {
		if (check[i] == esize) {
			cout << "YES" << endl;
			flag = 1;
			cout << i << endl;
		}
	}
	if(flag ==0)
	{
		cout << "NO" << endl;
	}
	return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
#include<limits.h>
using namespace std;
int arr[200010];
vector<int> G[200010];

struct edge {
	int u, v;
	edge() {};
	edge(int a, int b) {
		u = a;
		v = b;
	}
};
vector<edge> elist;
pair<int, int> temp[200010];
int color[200010];
int check[200010];
int main() {
//	freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		temp[i].first = u;
		temp[i].second = v;
	}
	for (int i = 1; i <= n; i++) {
		cin >> color[i];
	}

	int esize = 0;
	for (int i = 1; i < n; i++) {
		int u = temp[i].first;
		int v = temp[i].second;
		if (color[u] != color[v]) {
			elist.push_back(edge(u, v));
			esize++;
			check[u]++;
			check[v]++;
		}
	}
	int flag = 0;
	for (int i = 1; i <= n; i++) {
		if (check[i] == esize) {
			cout << "YES" << endl;
			flag = 1;
			cout << i << endl;
			return 0;
		}
	}
	if(flag ==0)
	{
		cout << "NO" << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,x,y,cnter=0;
	vector<int> p1,p2,color,b;
	cin >> n;
	for (int i = 1; i < n; i++){
		cin >> x >> y;
		p1.push_back(x);
		p2.push_back(y);
		b.push_back(0);
	}
	b.push_back(0);
	for (int i = 1; i <= n; i++){
		cin >> x;
		color.push_back(x);
	}
	for (int i = 0; i < n-1; i++){
		if (color[p1[i]-1] != color[p2[i]-1]){
			b[p1[i]-1]++;
			b[p2[i]-1]++;
			cnter++;
		}
	}
	for (int i = 0; i < n; i++){
		if (b[i] == cnter){
			cout << "YES" << endl;
			cout << (b[i]);
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    char* s[n]=null;
    for(int i=0; i<n; i++) {
       cin>>s[i];
    }
    for(int i=0; i<n; i++) {
        int len=strlen(s[i]);
        if(len>10) {
            cout<<s[i][0]<<len<<s[i][len-1];
        }
        else {
            cout<<s[i];
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main() {

    string s;
   s.size()>10?s[0]+s.size()+s[s.size()-1]:s;
   return 0;
    }


#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    char* s[n];
    for(int i=0; i<n; i++) {
       cin>>s[i];
    }
    for(int i=0; i<n; i++) {
        int len=strlen(s[i]);
        if(len>10) {
            cout<<s[i][0]<<len<<s[i][len-1];
        }
        else {
            cout<<s[i];
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main() {

   string s;
   cin>>s;
   while(cin>>s) {
       cout<<(s.size()>10?s[0]+to_string(s.size()-2)+s[s.size()-1]:s);
   }
   return 0;
    }


#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    string s[n];
    for(int num_of_strings=0; num_of_strings<n; num_of_strings++) {
        gets(s[num_of_strings]);
    }
    for(int i=0; i<n; i++) {
        int len=s[i].length();
        if(len>10) {
            cout<<s[i][0]<<len<<s[i][len-1];
        }
        else {
            cout<<s[i];
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main() {

   string s;
   cin>>s;
   while(cin>>s) {
       s.size()>10?cout<<s.at(0)+s.size()+s.at(s.size()-1):cout<<s;
   }
   return 0;
    }


#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    char* s[n];
    for(int i=0; i<n; i++) {
       cin>>s[i];
    }
    for(int i=0; i<n; i++) {
        int len=s[i].length();
        if(len>10) {
            cout<<s[i][0]<<len<<s[i][len-1];
        }
        else {
            cout<<s[i];
        }
    }

}


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>n){
cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1);
}else  cout<< ;
}
return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main(){
    string a;
    int b;

    cin >> b;
    while(true){
        cin >> a;
        if(a.length()>b){
            cout << a.at(0) << a.length()-2 << a.at(a.length()-1)<<"\n";
        }else{
            cout << a << "\n";
        }

    }
     return 0;
 }


#include<iostream>
#include<string>

using namespace std;

int main()
{
	int b;
	string a;
	cin >> b;

	while (b>0){
		--b;
		cin >> a;
		if(a.length()>10){
			cout<<a.at(0)<<a.length()-2<<a.at(a.length()-1)<< endl;
		}
		else{
			cout << a<<endl;
		}
	}

	return 0;
}


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>=n)
cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1)
}
return 0;
}


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>=n)
cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1);
}
return 0;
}


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>=n){cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1)
}
return 0;
}


#include <iostream>
#include <string>

int main(){

    using namespace std;

    string n;
    int a;
    cin >> a;
    while (a>0){
		a--;
		cin >> n;
		if(n.length()>10){
			cout<<n.at(0)<<n.length()-2<<n.at(n.length()-1);
		}
		else{
			cout << n;
		}

    }

	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main(){
    string a;
    int b;

    cin >> b;
    while(b>=1&&b<=100){
        cin >> a;
        if(a.length()>b){
            cout << a.at(0) << a.length()-2 << a.at(a.length()-1)<<"\n";
        }else{
            cout << a << "\n";
        }

    }
     return 0;
 }


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>n){
cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1);
}else  cout<< ;
}
}
return 0;
}


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>=n
cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1)
}
return 0;
}


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

int main(){
string a;
int n;
cin>>n;
while(true){
cin>>a;
if(a.length()>n){
cout <<a.at(0) <<a.length()-2<<a.at(a.length()-1);
}else  {cout<< a;
}
}
return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0, push=1;
	char z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>9){
		z = s[j][s[j].size()-1];
		sani = s[j].size();
		sanf = s[j].size();
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				cout<<"sanf="<<sanf<<endl;
				cout<<"sifr="<<sifr<<endl;
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				push++;
				}
				s[j][push]=(z);
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=0; j<4; j++){
			cout<<s[i][j];
		}
		cout<<endl;
	}
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0;
	char z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()-2>=9){
		z = s[j][s[j].size()-1];
		sani = s[j].size()-2;
		sanf = s[j].size()-2;
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				}
				s[j][sifr1+1]=z;
		}
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()-2<9 or s[j].size()==1)
			cout<<s[j]<<endl;
		else if(s[j].size()-2>9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<s[j][3]<<endl;
		if(s[j].size()-2==9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<endl;
	}
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0;
	char z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>9){
		z = s[j][s[j].size()-1];
		sani = s[j].size()-2;
		sanf = s[j].size()-2;
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				}
				s[j][3]=z;
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=0; j<4; j++){
			cout<<s[i][j];
		}
		cout<<endl;
	}
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0;
	char z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>=9){
		z = s[j][s[j].size()-1];
		sani = s[j].size()-2;
		sanf = s[j].size()-2;
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				}
				s[j][sifr1+1]=z;
		}
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()<9)
			cout<<s[j]<<endl;
		else if(s[j].size()>9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<s[j][3]<<endl;
		if(s[j].size()==9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<endl;
	}
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0, push=1;
	char z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>9){
		z = s[j][s[j].size()-1];
		sani = s[j].size()-2;
		sanf = s[j].size()-2;
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				push++;
				}
				s[j][push]=(z);
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=0; j<4; j++){
			cout<<s[i][j];
		}
		cout<<endl;
	}
}


#include<iostream>
#include<string>
using namespace std;
int main(){
	int n, z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>9)
		z=s[j].size()-1;
			for(int k=1; k<=s[j].size()-1; k++)
			s[j].pop_back();
				s[j]+=s[j].size()-2;
				s[j]+=z;
	}
	for(int i=1; i<=n; i++)
	cout<<s[i];
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0;
	char z;
	string s[10000];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()-2>=9){
		z = s[j][s[j].size()-1];
		sani = s[j].size()-2;
		sanf = s[j].size()-2;
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				}
				s[j][sifr1+1]=z;
		}
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()-2<9 or s[j].size()==1)
			cout<<s[j]<<endl;
		else if(s[j].size()-2>9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<s[j][3]<<endl;
		if(s[j].size()-2==9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<endl;
	}
}


#include<iostream>
#include<string>
using namespace std;
int main(){
	int n, z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>9)
		z=s[j].size()-1;
			for(int k=1; k<=s[j].size()-1; k++)
			s[j].pop_back();
				s[j]+=s[j].size()-2;
				s[j]+=z;
	}
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n, sani, sanf, sifr=0, sifr1=0;
	char z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()-2>=9){
		z = s[j][s[j].size()-1];
		sani = s[j].size()-2;
		sanf = s[j].size()-2;
		sifr=0;
		sifr1=0;
			while(sani!=0){
			sani/=10;
			sifr++;
			sifr1++;
			}
				for(int i=0; i<sifr1; i++){
				s[j][i+1]=(char(sanf/pow(10, sifr-1)+48));
				sanf=sanf-int(sanf/pow(10, sifr-1))*pow(10, sifr-1);
				sifr--;
				}
				s[j][sifr1+1]=z;
		}
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()-2<9)
			cout<<s[j]<<endl;
		else if(s[j].size()-2>9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<s[j][3]<<endl;
		if(s[j].size()-2==9)
			cout<<s[j][0]<<s[j][1]<<s[j][2]<<endl;
	}
}


#include<iostream>
#include<string>
using namespace std;
int main(){
	int n, z;
	string s[100];
	cin>>n;
	for(int i=1; i<=n; i++){
	cin>>s[i];
	}
	for(int j=1; j<=n; j++){
		if(s[j].size()>9)
		z=s[j].size()-1;
			for(int k=1; k<=s[j].size()-1; k++)
			s[j].pop_back();
				s[j]+=s[j].size()-2;
				s[j]+=z;
	}
	for(int i=1; i<=n; i++)
	cout<<s[i]<<endl;
}


#include <iostream >
#include <string>
usin namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
using namespace std ;
int main ()
{
int n, l;
cin>>n;
string ch;
for(i=0;i<n;i++)
{
cin>>ch;
if(ch.length()>10)
{
cout<<ch[0];
l=ch.length();
cout<<l-2;
cout<<ch[l-1]<<endl;
}
else
cout<<ch<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
using namespace std;
int main ()
{
int x,n;
cin>>n;
String ch[n];
for(int i=0;i<n;i++)
cin>>ch[i];
for(int i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length();
cout<<x-2;
cout<<ch[i][x-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string. h>
using namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
using namespace std;
int main ()
{
int x,n;
cin>>n;
if(n>=1&&n<=100)
String ch[n];
for(i=0;i<n;i++)
cin>>ch[i];
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}}
return 0;
}


#include <iostream >
#include <string >
usin namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string>
using namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
using namespace std ;
int main ()
{
int n, l;
cin>>n;
string ch;
for(int i=0;i<n;i++)
{
cin>>ch;
if(ch.length()>10)
{
cout<<ch[0];
l=ch.length();
cout<<l-2;
cout<<ch[l-1]<<endl;
}
else
cout<<ch<<endl;
}
return 0;
}


#include <iostream >
#include <cstring>
using namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
using namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
usin namespace std;
int main ()
{
int x,i,n,j;
cin>>n;
String ch[n];
for(i=0;i<n;i++)
{cin>>ch[i];}
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length()-2;
cout<<x;
for(j=0;j<ch[i].length();j++)
{}
cout<<ch[i][j-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <iostream >
#include <string.h>
using namespace std;
int main ()
{
int x,n;
cin>>n;
String ch[n];
for(int i=0;i<n;i++)
cin>>ch[i];
for(i=0;i<n;i++)
{
if(ch[i].length()>10)
{
cout<<ch[i][0];
x=ch[i].length();
cout<<x-2;
cout<<ch[i][x-1]<<endl;
}
else
cout<<ch[i]<<endl;
}
return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	string n;
	cin >> n;

	if(n.length() < 5){
		cout << n;
	}

	else if(n.length()>10){
	cout << n[0] << n.length()-2 << n.back();
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int  k;
	cin >>k;

	for(int i=0; i < 4; i++){
	string n;
	cin >> n;
		if(n.length() < 10){
		cout << n;
	}

	else if(n.length()>10){
	cout << n[0] << n.length()-2 << n.back();
	}
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int  s;
	cin >>s;

	for(int i=0; i < s; i++){
	string n;
	cin >> n;	;
		if(n.length() < 10){
		cout << n;
	}

	else if(n.length()>10){
	cout << n[0] << n.length()-2 << n.back();
	}
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int  n;
	cin >>n;

	for(int i=0; i < n +1; i++){
	string s;
	cin >> s;
		if(s.length() < 10){
		cout << s<< endl;
	}

	else if(s.length()>10){
	cout << s[0] << s.length()-2 << s.back()<< endl;
	}
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	string n;
	cin >> n;

	if(n.length() < 5){
		cout << n;
	}

	else{
	cout << n[0] << n.length()-2 << n.back();
	}
}


#include <string.h>
#include <iostream>
using namespace std;

int main(){
	string n;
	cin >> n;
	int t = n.length() -2;

	if(n.length() > 10){
		cout << n[0] << t << n.back();
	}

	else{
		cout << n;
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int  n;
	cin >>n;

	for(int i=-1; i < n; i++){
	string s;
	cin >> s;
		if(s.length() < 10){
		cout << s<< endl;
	}

	else if(s.length()>10){
	cout << s[0] << s.length()-2 << s.back()<< endl;
	}
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	string n;
	cin >> n;

	if(n.length() < 10){
		cout << n;
	}

	else if(n.length()>10){
	cout << n[0] << n.length()-2 << n.back();
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int  n;
	cin >>n;

	for(int i=0; i < n +1; i++){
	string s;
	cin >> s;
		if(s.length() <= 10){
		cout << s<< endl;
	}

	else if(s.length()>10){
	cout << s[0] << s.length()-2 << s.back()<< endl;
	}
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

	int  n;
	cin >>n;

	for(int i=0; i < n; i++){
	string s;
	cin >> s;
		if(s.length() < 10){
		cout << s<< endl;
	}

	else if(s.length()>10){
	cout << s[0] << s.length()-2 << s.back()<< endl;
	}
	}
}


#include <iostream>
using namespace std;

int main(void) {
	string s;
	int x;
	cin >> x;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
	}
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	string l = to_string(s.length() - 2);
	if(s.length() > 10) cout << s[0] + l + s.back() << endl;
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 4;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 4;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 200;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
	}
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 5;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 4;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl;
		x--;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 10;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
	}
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 5;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10 && !s.at(0) == "4") cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 1;
	while(1 < 2) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10) cout << s[0] + l + s.back() << endl; else cout << s << endl;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	string l = to_string(s.Length() - 2);
	if(s.Length() > 10) cout << s[0] + l + s.back() << endl;
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	int x = 5;
	while(x != 0) {
		cin >> s;
	    string l = to_string(s.length() - 2);
	    if(s.length() > 10 && !s[0] == "4") cout << s[0] + l + s.back() << endl; else cout << s << endl;
		x--;
    }
}


#include <iostream>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	string l = to_string(s.length() - 2);
	if(s.length() > 10) cout << to_string(s[0] + l + s.back()) << endl;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    string word;

    for(int i; i<n; i++)
    {
        string lword;
        cin >> word;
        if ((word.length()/(sizeof(string)))>10)
        {
            lword+=word.front();
            lword+=(word.length())/sizeof(string);
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring.h>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=strlen(word.c_str());
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    string word;

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)word.length() + 2;
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=((int)word.size());
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)word.length();
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (word.length()>10)
        {
            string lword;
            cout << word.front() << (word.length()-2) << word.back() << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=word.size();
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=strlen(word.c_str());
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (word.length()>10)
        {
            string lword;
            lword+=word.front();
            lword+=strlen(word.c_str());
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)(strlen(word.c_str()));
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(char&)(strlen(word.c_str()));
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (word.length()>10)
        {
            cout << word.length() << endl;
            string lword;
            lword+=word.front();
            lword+=strlen(word.c_str());
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)word.size();
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=word.length();
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)(strlen(word.c_str()));
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (word.length()>10)
        {
            string lword;
            cout << word.front() << word.length() << word.back() << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (word.length()>10)
        {

            string lword;
            cout << word.front() << word.length() << word.back() << endl;;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=((int)word.length());
            lword+=word.back();

            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>
#include <cstring>

using namespace std;

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

    for(int i=0; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(char)(strlen(word.c_str()));
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    string word;

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)word.length();
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(word.size()/sizeof(string));
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    string word;

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)word.lenght();
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)(word.size()/sizeof(string));
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


#include <iostream>

using namespace std;

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

    for(int i; i<n; i++)
    {
        cin >> word;
        if (((int)word.length())>10)
        {
            string lword;
            lword+=word.front();
            lword+=(int)word.length() + 2;
            lword+=word.back();
            cout << lword << endl;
        }
        else
            cout << word << endl;

    }
}


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

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {

			getline(cin, str[i]);

	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
}


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

double test(string str) {
	for(int i = 0; i < str.length(); i++) {
		if(str[i] >= 65 && str[i] <= 90) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {
		do {
			getline(cin, str[i]);
		} while(!test(str[i]));
	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
}


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

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {

			getline(cin, str[i]);

	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	return 0;
}


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

int main() {
	int n;
	char **str;
		cin>>n;
	str = new char*[n];
	for(int i = 0; i < n; i++) {
		str[i] = new char[100];
	}
	for(int i = 0; i < n; i++) {
			fflush(stdin);
			gets(str[i]);

	}
	for(int i = 0; i < n; i++) {
		if(strlen(str[i]) > 10) {
			cout<<str[i][0]<<strlen(str[i])-2<<str[i][strlen(str[i]) - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	return 0;
}


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

double test(string str) {
	if(str.length() < 1 || str.length() > 100) {
		return false;
	}
	for(int i = 0; i < str.length(); i++) {
		if(str[i] >= 65 && str[i] <= 90) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {
		do {
			getline(cin, str[i]);
		} while(!test(str[i]));
	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	return 0;
}


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

int main() {
	int n;
	char **str;
	char swap[100];
		cin>>n;
	str = new char*[n];

	for(int i = 0; i < n; i++) {
			fflush(stdin);
			gets(swap);
			str[i] = new char[strlen(swap)];
			strcpy(str[i], swap);

	}
	for(int i = 0; i < n; i++) {
		if(strlen(str[i]) > 10) {
			cout<<str[i][0]<<strlen(str[i])-2<<str[i][strlen(str[i]) - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	for(int i = 0; i < n; i++) {
		delete[] str[i];
	}
	delete[] str;
	return 0;
}


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

int main() {
	int n;
	string *str;
		cin>>n;
	str = new string[n];

	for(int i = 0; i < n; i++) {
			fflush(stdin);
			getline(cin, str[i]);

	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	return 0;
}


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

int main() {
	string s;
	cin>>s;
	while(cin>>s) {
		if(s.length() > 10) {
			cout<<s[0]<<s.length()-2<<s[s.length() - 1]<<endl;
		}
		else {
			cout<<s<<endl;
		}
	}
	return 0;
}


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

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {
		cin>>str[i];
	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	return 0;
}


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

double test(string str) {
	if(str.length() < 1 || str.length() > 100) {
		return false;
	}
	for(int i = 0; i < str.length(); i++) {
		if(str[i] >= 65 && str[i] <= 90) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {
		do {
			getline(cin, str[i]);
		} while(!test(str[i]));
	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
	return 0;
}


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

double test(string str) {
	if(str.length() < 1 || str.length() > 100) {
		return false;
	}
	for(int i = 0; i < str.length(); i++) {
		if(str[i] >= 65 && str[i] <= 90) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	string *str;
	do {
		cin>>n;
	} while(n < 1 || n > 100);
	str = new string[n];
	fflush(stdin);
	for(int i = 0; i < n; i++) {
		do {
			getline(cin, str[i]);
		} while(!test(str[i]));
	}
	for(int i = 0; i < n; i++) {
		if(str[i].length() > 10) {
			cout<<str[i][0]<<str[i].length()-2<<str[i][str[i].length() - 1]<<endl;
		}
		else {
			cout<<str[i]<<endl;
		}
	}
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        ArrayList<Integer> order = new ArrayList<>();
        boolean[][] adj = new boolean[101][101];
        int count = 0;
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[count] = l;
                right[count] = r;
                update(adj, left, right);
                count++;
            }
            else{
                if(bfs(adj, l-1, r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i+1; j < adj.length; j++){
                if(left[i] < right[j] && left[i] > left[j] ||
                        right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Interval> invs = new ArrayList<>();
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                invs.add(new Interval(l,r));
                update(invs);
            }
            else{
                if(invs.get(l-1).canReach.contains(r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static void update(ArrayList<Interval> invs){
        invs.get(invs.size()-1).canReach.add(invs.size()-1);
        for(int j = 0; j < 2; j++)
            for(int i = invs.size()-1; i >= 0; i--){
                Interval newest = invs.get(invs.size()-1);
                if(invs.get(i).left < newest.right && invs.get(i).left > newest.left||
                    invs.get(i).right > newest.left && invs.get(i).right < newest.right) {
                    invs.get(i).canReach.addAll(newest.canReach);
                    newest.canReach.addAll(invs.get(i).canReach);
                }
            }
        }
}

class Interval{
    int left, right;
    HashSet<Integer> canReach;
    public Interval(int left, int right){
        this.left = left; this.right = right;
        canReach = new HashSet<>();
    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Interval> invs = new ArrayList<>();
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                invs.add(new Interval(l,r));
                update(invs);
            }
            else{
                if(invs.get(l).canReach.contains(r))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static void update(ArrayList<Interval> invs){
        invs.get(invs.size()-1).canReach.add(invs.size()-1);
        for(int j = 0; j < 2; j++)
            for(int i = invs.size()-1; i >= 0; i--){
                Interval newest = invs.get(invs.size()-1);
                if(invs.get(i).left < newest.right ||
                    invs.get(i).right > newest.left) {
                    invs.get(i).canReach.addAll(newest.canReach);
                    newest.canReach.addAll(invs.get(i).canReach);
                }
            }
        }
}

class Interval{
    int left, right;
    HashSet<Integer> canReach;
    public Interval(int left, int right){
        this.left = left; this.right = right;
        canReach = new HashSet<>();
    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Interval> invs = new ArrayList<>();
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                invs.add(new Interval(l,r));
                update(invs);
            }
            else{
                if(bfs(invs, l-1, r-1, new boolean[invs.size()]))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(ArrayList<Interval> invs, int src, int dest, boolean[] visited){
        visited[src] = true;
        if(invs.get(src).canReach.contains(dest))
            return true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (Integer nxt : invs.get(src).canReach) {
                if(nxt == dest)
                    return true;
                if (!visited[nxt]) {
                    visited[nxt] = true;
                    q.add(nxt);
                }
            }
        }
        return false;
    }
    static void update(ArrayList<Interval> invs){
        invs.get(invs.size()-1).canReach.add(invs.size()-1);

        for(int i = invs.size()-1; i >= 0; i--) {
            Interval newest = invs.get(invs.size() - 1);
            if (invs.get(i).left < newest.right && invs.get(i).left > newest.left ||
                    invs.get(i).right > newest.left && invs.get(i).right < newest.right) {
                newest.canReach.addAll(invs.get(i).canReach);
            }
            if (newest.left < invs.get(i).right && newest.left > invs.get(i).left ||
                    newest.right > invs.get(i).left && newest.right < invs.get(i).left) {
                invs.get(i).canReach.addAll(newest.canReach);
            }
        }

    }
}

class Interval{
    int left, right;
    HashSet<Integer> canReach;
    public Interval(int left, int right){
        this.left = left; this.right = right;
        canReach = new HashSet<>();
    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        for(int i = 0; i < left.length; i++){
            left[i] = Integer.MAX_VALUE;
            right[i] = Integer.MIN_VALUE;
        }
        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[i] = l;
                right[i] = r;
                update(adj, left, right);
            }
            else{
                if(bfs(adj, l-1, r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i+1; j < adj.length; j++){
                if(left[i] < right[j] && left[i] > left[j] ||
                    right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[i] = l;
                right[i] = r;
                update(adj, left, right);
            }
            else{
                if(bfs(adj, l-1, r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Stack<Integer> s = new Stack<>();
        s.add(src);
        while(!s.isEmpty()) {
            src = s.pop();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    s.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i+1; j < adj.length; j++){
                if(left[i] < right[j] && left[i] > left[j] ||
                    right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];

        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[i] = l;
                right[i] = r;
                update(adj, left, right);
            }
            else{
                if(bfs(adj, l-1, r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i+1; j < adj.length; j++){
                if(left[i] < right[j] && left[i] > left[j] ||
                    right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Interval> invs = new ArrayList<>();
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                invs.add(new Interval(l,r));
                update(invs);
            }
            else{
                if(invs.size() != 0 && invs.get(l-1).canReach.contains(r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static void update(ArrayList<Interval> invs){
        invs.get(invs.size()-1).canReach.add(invs.size()-1);
        for(int j = 0; j < invs.size(); j++)
            for(int i = invs.size()-1; i >= 0; i--){
                Interval newest = invs.get(invs.size()-1);
                if(invs.get(i).left < newest.right && invs.get(i).left > newest.left||
                    invs.get(i).right > newest.left && invs.get(i).right < newest.right) {
                    invs.get(i).canReach.addAll(newest.canReach);
                    newest.canReach.addAll(invs.get(i).canReach);
                }
            }
        }
}

class Interval{
    int left, right;
    HashSet<Integer> canReach;
    public Interval(int left, int right){
        this.left = left; this.right = right;
        canReach = new HashSet<>();
    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        for(int i = 0; i < left.length; i++){
            left[i] = Integer.MAX_VALUE;
            right[i] = Integer.MAX_VALUE;
        }
        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[i] = l;
                right[i] = r;
                update(adj, left, right);
            }
            else{
                if(bfs(adj, l-1, r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i+1; j < adj.length; j++){
                if(left[i] == Integer.MAX_VALUE)
                    continue;
                if(left[i] < right[j] && left[i] > left[j] ||
                    right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        for(int i = 0; i < left.length; i++){
            left[i] = Integer.MIN_VALUE;
            right[i] = Integer.MIN_VALUE;
        }
        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt() - 1; int r = sc.nextInt() - 1;
            if(q == 1){
                left[i] = l;
                right[i] = r;
                update(adj, left, right);
            }
            else{
                if(bfs(adj, l, r))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i; j < adj.length; j++){
                if(left[i] == Integer.MIN_VALUE)
                    continue;
                if(left[i] < right[j] && left[i] > left[j] ||
                    right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        for(int i = 0; i < left.length; i++){
            left[i] = Integer.MIN_VALUE; right[i] = Integer.MIN_VALUE;
        }
        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[i] = l;
                right[i] = r;
                update(adj, left, right);
            }
            else{
                if(bfs(adj, l-1, r-1))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            if(left[i] == Integer.MIN_VALUE)
                continue;
            for(int j = i+1; j < adj.length; j++){
                if(left[j] == Integer.MIN_VALUE)
                    continue;
                assert(left[i] != Integer.MIN_VALUE);
                assert(right[i] != Integer.MIN_VALUE);
                assert(left[j] != Integer.MIN_VALUE);
                assert(right[j] != Integer.MIN_VALUE);
                if(left[i] < right[j] && left[i] > left[j] ||
                        right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Interval> invs = new ArrayList<>();
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                invs.add(new Interval(l,r));
                update(invs);
            }
            else{
                if(bfs(invs, l-1, r-1, new boolean[invs.size()]))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(ArrayList<Interval> invs, int src, int dest, boolean[] visited){
        visited[src] = true;
        if(invs.get(src).canReach.contains(dest))
            return true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (Integer nxt : invs.get(src).canReach) {
                if(nxt == dest)
                    return true;
                if (!visited[nxt])
                    q.add(nxt);
            }
        }
        return false;
    }
    static void update(ArrayList<Interval> invs){
        invs.get(invs.size()-1).canReach.add(invs.size()-1);

        for(int i = invs.size()-1; i >= 0; i--) {
            Interval newest = invs.get(invs.size() - 1);
            if (invs.get(i).left < newest.right && invs.get(i).left > newest.left ||
                    invs.get(i).right > newest.left && invs.get(i).right < newest.right) {
                invs.get(i).canReach.addAll(newest.canReach);
                newest.canReach.addAll(invs.get(i).canReach);
            }
        }

    }
}

class Interval{
    int left, right;
    HashSet<Integer> canReach;
    public Interval(int left, int right){
        this.left = left; this.right = right;
        canReach = new HashSet<>();
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class test {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] left = new int[101];
        int[] right = new int[101];
        ArrayList<Integer> order = new ArrayList<>();
        boolean[][] adj = new boolean[101][101];
        for(int i = 0; i < n; i++){
            int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt();
            if(q == 1){
                left[i] = l;
                right[i] = r;
                order.add(i);
                update(adj, left, right);
            }
            else{
                if(bfs(adj, order.get(l-1), order.get(r-1)))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }
    static boolean bfs(boolean[][] adj, int src, int dest){
        boolean[] visited = new boolean[adj.length];
        visited[src] = true;
        Queue<Integer> q = new LinkedList<>();
        q.add(src);
        while(!q.isEmpty()) {
            src = q.poll();
            for (int i = 0; i < adj.length; i++) {
                if(adj[src][i] && i == dest)
                    return true;
                if (adj[src][i] && !visited[i]) {
                    visited[i] = true;
                    q.add(i);
                }
            }
        }
        return false;
    }
    static void update(boolean[][] adj, int[] left, int[] right){
        for(int i = 0; i < adj.length - 1; i++){
            adj[i][i] = true;
            for(int j = i+1; j < adj.length; j++){
                if(left[i] < right[j] && left[i] > left[j] ||
                        right[i] < right[j] && right[i] > left[j]){
                    adj[i][j] = true;
                }
                if(left[j] < right[i] && left[j] > left[i] ||
                        right[j] < right[i] && right[j] > left[i]){
                    adj[j][i] = true;
                }
            }
        }

    }
}


import java.util.*;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class Hello {
  static int []vis = new int[1000];

  static void GO(ArrayList<Integer>a, ArrayList<Integer>b, int n)
  {
    if (vis[n] == 1) return;
    vis[n] = 1;
    for (int j = 0;j < a.size();++j) {
      if (j == n) continue;
      int good = 0;
      if (a.get(n) > a.get(j) && a.get(n) < b.get(j)) good = 1;
      if (b.get(n) > a.get(j) && b.get(n) < b.get(j)) good = 1;
      if (good == 1) GO(a, b, j);
    }
  }
  public static void main(String[] args) {
    //try {
    //  FileInputStream fis = new FileInputStream("data.txt");
    //  System.setIn(fis);
      Scanner in = new Scanner(System.in);

      ArrayList<Integer> a = new ArrayList();
      ArrayList<Integer> b = new ArrayList();

      int n = in.nextInt();
      for (int i = 0;i < n;++i) {
	int n1 = in.nextInt();
	int n2 = in.nextInt();
	int n3 = in.nextInt();
	if (n1 == 1) {
	  a.add(n2);
	  b.add(n3);
	} else {
	  for (int j = 0;j < a.size();++j) {
	    vis[j] = 0;
	  }
	  n2 = n2 - 1;
	  n3 = n3 - 1;
	  GO(a, b, n2);
	  if (vis[n3] == 1) {
	    System.out.println("YES");
	  } else {
	    System.out.println("NO");
	  }
	}
      }
    //} catch (FileNotFoundException e){
    //  System.out.println("error");
    //}
  }
}


import java.util.*;

public class PingPong {

    static ArrayList < LinkedList < Integer >> adjs = new ArrayList < > ();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numQueries = sc.nextInt();
        ArrayList < Interval > intervals = new ArrayList < > ();
        ArrayList < String > ans = new ArrayList < > ();
        for (int i = 0; i < numQueries; i++) {
            int type = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (type == 1) {
                Interval newNode = new Interval(x, y);
                int newNodeIndex = intervals.size();
                intervals.add(newNode);
                adjs.add(new LinkedList < > ());

                for (int j = 0; j < intervals.size(); j++) {
                    if (intervals.get(j).canMoveTo(newNode)) {
                        adjs.get(j).add(newNodeIndex);
                    }
                    if (newNode.canMoveTo(intervals.get(j))) {
                        adjs.get(newNodeIndex).add(j);
                    }
                }
            } else {
                if (hasPath(x - 1, y - 1)) {
                    ans.add("YES");
                } else {
                    ans.add("NO");
                }
            }
        }

        for (String s: ans) {
            System.out.println(s);
        }
    }

    static boolean hasPath(int start, int dest) {
        LinkedList < Integer > toVisit = new LinkedList < > ();
        HashSet < Integer > visited = new HashSet < > ();
        toVisit.add(start);
        while (!toVisit.isEmpty()) {
            int curNode = toVisit.remove();
            visited.add(curNode);
            for (int node: adjs.get(curNode)) {
                if (node == dest) {
                    return true;
                }
                if (!visited.contains(node)) {
                    toVisit.add(node);
                }
            }
        }
        return false;
    }

    static class Interval {
        int low, high;

        Interval(int low, int high) {
            this.low = low;
            this.high = high;
        }

        private boolean canMoveTo(Interval next) {
            return low > next.low && low < next.high ||
                    high > next.low && high < next.high;
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class PingPong {
    static int MAXN = 102;
    static int[] a = new int[MAXN];
    static int[] b = new int[MAXN];
    static boolean[] seen = new boolean[MAXN];
    static int count = 1;

    static void dfs(int s, int e) {
        seen[s] = true;
        if (seen[e]) return;
        for (int i = 1; i < count; i++) {
            if (seen[i]) continue;
            if (a[s] > a[i] && a[s] < b[i]) dfs(i, e);
            if (seen[e]) return;
            if (b[s] > a[i] && b[s] < b[i]) dfs(i, e);
            if (seen[e]) return;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<String> ans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (m == 1) {
                a[count] = x;
                b[count] = y;
                count++;
            } else {
                dfs(x, y);
                if (seen[y]) ans.add("YES");
                else ans.add("NO");
            }
        }

        for (String s: ans) {
            System.out.println(s);
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class PingPong {
    static int MAXN = 102;
    static int[] a = new int[MAXN];
    static int[] b = new int[MAXN];
    static boolean[] seen = new boolean[MAXN];
    static int count;

    static void dfs(int s, int e) {
        seen[s] = true;
        if (seen[e]) return;
        for (int i = 1; i < count; i++) {
            if (seen[i]) continue;
            if (a[s] > a[i] && a[s] < b[i]) dfs(i, e);
            if (seen[e]) return;
            if (b[s] > a[i] && b[s] < b[i]) dfs(i, e);
            if (seen[e]) return;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<String> ans = new ArrayList<>();
        count = 1;
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (m == 1) {
                a[count] = x;
                b[count] = y;
                count++;
            } else {
                dfs(x, y);
                if (seen[y]) ans.add("YES");
                else ans.add("NO");
            }
        }

        for (String s: ans) {
            System.out.println(s);
        }
    }
}


import java.awt.*;
import java.util.*;
import java.io.*;
public class dear {
	static int end = 0;
	static int special1 = 1;
	static Stack<Point> stack;
	static HashMap<Point, Integer> nodeInGraph = new HashMap<>();
	static ArrayList<Point> graph = new ArrayList<>();
	static int qur_Num;
	static int special2 = 2;

	public static boolean DFS(int a, int b, ArrayList<Point> graph) {
        boolean[] visited = new boolean[graph.size()];
        stack = new Stack<Point>();
        stack.push(graph.get(a));

        while (!stack.isEmpty()) {
            Point node = stack.pop();
            if (visited[nodeInGraph.get(node)] == false) {
                visited[nodeInGraph.get(node)] = true;
                if (node.equals(graph.get(b))) {
                    return true;
                }
                for (Point p : graph) {
                    if (!p.equals(node) && !visited[nodeInGraph.get(p)] &&
                		node.x > p.x && node.x < p.y ||
                		node.y > p.x && node.y < p.y) {
                    	stack.push(p);
                    }
                }
            }
        }
        return false;
    }

    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        qur_Num = scan.nextInt();
        while (qur_Num > end) {
            int qur = scan.nextInt();
            if (special2 == qur) {
            	System.out.println(DFS(scan.nextInt()-1, scan.nextInt()-1, graph) ?
                        "YES" : "NO");
            }else if (qur == special1) {
                Point p = new Point(scan.nextInt(), scan.nextInt());
                nodeInGraph.put(p, graph.size());
                graph.add(p);
            }
            qur_Num--;
        }
    }
}


import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.nextLine();
		ArrayList<Vertex> graph = new ArrayList<>();

		for(int i=0; i < n; i++) {
			int type = in.nextInt();
			if (type == 1) {
				int a = in.nextInt();
				int b = in.nextInt();
				Vertex temp = new Vertex(a, b, graph.size() + 1);
				for(int j = 0; j < graph.size(); j++) {
					Vertex v = graph.get(j);
					int c = v.interval_start;
					int d = v.interval_end;
					if ((c < a && c < d && a < d) || (c < b && c < d && b < d))
						temp.addNeighbor(v.when_added);
					if ((a < c && c < b && a < b) || (a < d && a < b && d < b))
						v.addNeighbor(graph.size() + 1);
				}
				graph.add(temp);
			} else {
				int start = in.nextInt();
				int end = in.nextInt();
				for (Vertex v : graph) {
					v.visited = false;
				}
				if (BFS(graph, start, end)) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			}
		}
	}

	public static boolean BFS(ArrayList<Vertex> graph, int start, int end) {
		PriorityQueue<Vertex> visited = new PriorityQueue<>();
		Vertex begin = graph.get(start-1);
		visited.add(begin);

		while (!visited.isEmpty()) {
			Vertex cur = visited.poll();

			if (cur.visited) {
				continue;
			}

			if (cur.when_added == end) {
				return true;
			} else {
				cur.visited = true;
				for(int n : cur.neighbors) {
					Vertex neighbor = graph.get(n-1);
					if (!neighbor.visited) {
						visited.add(neighbor);
					}
				}
			}
		}
		return false;
	}

	private static class Vertex implements Comparable<Vertex> {
		int when_added;
		int interval_start;
		int interval_end;
		boolean visited;
		ArrayList<Integer> neighbors;

		public Vertex(int start, int end, int when_added) {
			this.interval_start = start;
			this.interval_end = end;
			this.neighbors = new ArrayList<>();
			this.when_added = when_added;
			this.visited = false;
		}

		public void addNeighbor(int when_added) {
			neighbors.add(when_added);
		}

		public int compareTo(Vertex o) {
			return this.when_added - o.when_added;
		}
	}
}


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Ping_Pong {

	public static void main(String[] args) {
		// we are really just doing a Breadth first search
		// hard part is figure out if any nodes connects to the other
//	    InputStreamReader isr = new InputStreamReader(System.in);
//		BufferedReader in = new BufferedReader(isr);
		Scanner in = new Scanner(System.in);
		int cases = in.nextInt();
		in.nextLine();
		int totalAdded = 0;
		// the graph will be a list of nodes and their neighbors
		ArrayList<Vertex> graph = new ArrayList<>();
		for(int i=0; i < cases; i++)
		{
			int type = in.nextInt();
			// node insertion
			if(type == 1)
			{
				int a = in.nextInt();
				int b = in.nextInt();
				Vertex temp = new Vertex(a, b, totalAdded+1);
				// now we loop through our vertex list and check if existing
				// can reach this vertex
				for(int j = 0; j < totalAdded; j++)
				{
					Vertex v = graph.get(j);
					int c = v.interval_start;
					int d = v.interval_end;
					// cam we get to this node from new node?
					if ((c < a && c < d && a < d) || (c < b && c < d && b < d))
						temp.addNeighbor(v.when_added);
					// can we get to new node from this node?
					if ((a < c && c < b && a < b) || (a < d && a < b && d < b))
						v.addNeighbor(totalAdded+1);
				}
				// can now safely insert
				graph.add(temp);
				totalAdded++;
				// System.out.println("Current graphs");
				// System.out.println(graph.toString());
			}
			else
			{
				// note the interval to start and end at
				int start = in.nextInt();
				int end = in.nextInt();
				// gotta reset state
				for(Vertex v : graph)
					v.visited = false;
				if(BFS(graph, start, end))
					System.out.println("YES");
				else
					System.out.println("NO");
			}

		}
	}

	public static boolean BFS(ArrayList<Vertex> graph, int start, int end)
	{
		LinkedList<Vertex> toVisit = new LinkedList<>();
		// always from index 1 to n
		Vertex begin = graph.get(start-1);
		toVisit.add(begin);
		while (!toVisit.isEmpty())
		{
			Vertex cur = toVisit.poll();
			// System.out.println("Current node is " + cur.toString());
			// did we find it?
			if (cur.visited)
				continue;
			else if (cur.when_added == end)
				return true;
			else
			{
				// traverse its neighbors
				cur.visited = true;
				for(int n : cur.neighbors)
				{
					Vertex neighbor = graph.get(n-1);
					// if has not visited neighbor
					if (!neighbor.visited)
						toVisit.add(neighbor);
				}
			}
		}
		return false;
	}
	private static class Vertex implements Comparable<Vertex>
	{
		int when_added;
		int interval_start;
		int interval_end;
		boolean visited;
		ArrayList<Integer> neighbors;
		public Vertex(int a, int b, int when_added)
		{
			this.interval_start = a;
			this.interval_end = b;
			neighbors = new ArrayList<>();
			this.when_added = when_added;
			this.visited = false;
		}
		public void addNeighbor(int when_added)
		{
			neighbors.add(when_added);
		}
		@Override
		public int compareTo(Vertex o)
		{
			Vertex another = (Vertex) o;
			return this.when_added - another.when_added;
		}
		@Override
		public String toString()
		{
			return String.format("Interval: %d, %d; added: %d; visited %s; neighbors: %s;",
					interval_start, interval_end, when_added, visited, neighbors.toString());
		}
	}
}