#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n;
vector<int>adj[N];
int fa[N],dis[N];
int dfs(int u)
{
	dis[u]=dis[fa[u]]+1;
	int mxd=u,nmxd;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if(v==fa[u])continue;
		fa[v]=u;
		nmxd=dfs(v);
		if(dis[mxd]<dis[nmxd])mxd=nmxd;
	}
	return mxd;
}
int vis[N],d[N],num,deg[N];
int q[N],p,now,ans[N];
int main()
{
	n=read();
	int u,v;
	for(int i=1;i<n;i++)
	{
		u=read();v=read();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int s,t;
	fa[1]=0;dis[1]=0;s=dfs(1);
	fa[s]=0;dis[s]=0;t=dfs(s);
	for(;t;t=fa[t]){
		vis[t]=1;d[++num]=t;
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i])continue;
		int pas=0;
		for(int k=0;k<adj[i].size();k++)
		{
			int v=adj[i][k];
			if(vis[v]){
				pas=1;deg[v]++;
			}
		}
		if(!pas){
			puts("-1");
			return 0;
		}
	}
	
	p=0,now=1;
	for(int i=1;i<=num;i++)
	{
		for(int j=1;j<=deg[d[i]];j++)
			q[++p]=now+j;
		q[++p]=now;
		now=now+deg[d[i]]+1;
	}
	
	for(int i=1;i<=n;i++)ans[i]=q[i];
	
	p=0,now=1;
	for(int i=num;i>=1;i--)
	{
		for(int j=1;j<=deg[d[i]];j++)
			q[++p]=now+j;
		q[++p]=now;
		now=now+deg[d[i]]+1;
	}
	int ok=0;
	for(int i=1;i<=n;i++){
		if(q[i]<ans[i]){
			ok=1;
			break;
		}
		if(q[i]>ans[i])break;
	}
	if(!ok)for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	else for(int i=1;i<=n;i++)printf("%d ",q[i]);
	printf("\n");
	return 0;
}
### Prompt

Please create a solution in cpp to the following problem:

Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process:

First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation:

* If p_i = 1, do nothing.
* If p_i \neq 1, let j' be the largest j such that p_j < p_i. Span an edge between Vertex i and Vertex j'.



Takahashi is trying to make his favorite tree with this ability. His favorite tree has n vertices from Vertex 1 through Vertex n, and its i-th edge connects Vertex v_i and w_i. Determine if he can make a tree isomorphic to his favorite tree by using a proper permutation. If he can do so, find the lexicographically smallest such permutation.

Constraints

* 2 \leq n \leq 10^5
* 1 \leq v_i, w_i \leq n
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:


n
v_1 w_1
v_2 w_2
:
v_{n-1} w_{n-1}


Output

If there is no permutation that can generate a tree isomorphic to Takahashi's favorite tree, print `-1`. If it exists, print the lexicographically smallest such permutation, with spaces in between.

Examples

Input

6
1 2
1 3
1 4
1 5
5 6


Output

1 2 4 5 3 6


Input

6
1 2
2 3
3 4
1 5
5 6


Output

1 2 3 4 5 6


Input

15
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15


Output

-1

### Response

```cpp
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n;
vector<int>adj[N];
int fa[N],dis[N];
int dfs(int u)
{
	dis[u]=dis[fa[u]]+1;
	int mxd=u,nmxd;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if(v==fa[u])continue;
		fa[v]=u;
		nmxd=dfs(v);
		if(dis[mxd]<dis[nmxd])mxd=nmxd;
	}
	return mxd;
}
int vis[N],d[N],num,deg[N];
int q[N],p,now,ans[N];
int main()
{
	n=read();
	int u,v;
	for(int i=1;i<n;i++)
	{
		u=read();v=read();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int s,t;
	fa[1]=0;dis[1]=0;s=dfs(1);
	fa[s]=0;dis[s]=0;t=dfs(s);
	for(;t;t=fa[t]){
		vis[t]=1;d[++num]=t;
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i])continue;
		int pas=0;
		for(int k=0;k<adj[i].size();k++)
		{
			int v=adj[i][k];
			if(vis[v]){
				pas=1;deg[v]++;
			}
		}
		if(!pas){
			puts("-1");
			return 0;
		}
	}
	
	p=0,now=1;
	for(int i=1;i<=num;i++)
	{
		for(int j=1;j<=deg[d[i]];j++)
			q[++p]=now+j;
		q[++p]=now;
		now=now+deg[d[i]]+1;
	}
	
	for(int i=1;i<=n;i++)ans[i]=q[i];
	
	p=0,now=1;
	for(int i=num;i>=1;i--)
	{
		for(int j=1;j<=deg[d[i]];j++)
			q[++p]=now+j;
		q[++p]=now;
		now=now+deg[d[i]]+1;
	}
	int ok=0;
	for(int i=1;i<=n;i++){
		if(q[i]<ans[i]){
			ok=1;
			break;
		}
		if(q[i]>ans[i])break;
	}
	if(!ok)for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	else for(int i=1;i<=n;i++)printf("%d ",q[i]);
	printf("\n");
	return 0;
}
```