#include<bits/stdc++.h>

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,tot;
int v[200005],nxt[200005],h[100005],du[100005],dep[100005],f[100005],ans[100005];
bool vis[100005];
vector<int> vec;

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot; du[x]++;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot; du[y]++;
}

void dfs(int u,int fa){
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dep[v[p]]=dep[u]+1,f[v[p]]=u;
		dfs(v[p],u);
	}
}

int main(){
	n=readint();
	for(int i=1;i<n;i++) addedge(readint(),readint());
	dep[1]=f[1]=0; dfs(1,-1);
	int maxa=0,x=0,y=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,dep[i])) x=i;
	dep[x]=f[x]=0; dfs(x,-1);
	maxa=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,dep[i])) y=i;
	vis[x]=vis[y]=1;
	int tmp=f[y];
	while(tmp!=x) vec.push_back(du[tmp]-1),vis[tmp]=1,tmp=f[tmp];
	for(int i=1;i<=n;i++) if(!vis[i]&&nxt[h[i]]) return printf("-1\n"),0;
	int tl=0,tr=vec.size()-1,fl=0;
	for(int i=0;i<vec.size();i++){
		if(vec[tl]>vec[tr]) fl=-1;
		else if(vec[tl]<vec[tr]) fl=1;
		tl++,tr--;
		if(fl!=0) break;
	}
	if(fl<0) reverse(vec.begin(),vec.end());
	ans[1]=1,ans[n]=n;
	int now=1;
	for(int i=0;i<vec.size();i++){
		for(int j=2;j<=vec[i];j++) ans[now+j-1]=now+j;
		ans[now+vec[i]]=now+1;
		now+=vec[i];
	}
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}
### Prompt

Your challenge is to write a CPP solution 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 y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,tot;
int v[200005],nxt[200005],h[100005],du[100005],dep[100005],f[100005],ans[100005];
bool vis[100005];
vector<int> vec;

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot; du[x]++;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot; du[y]++;
}

void dfs(int u,int fa){
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dep[v[p]]=dep[u]+1,f[v[p]]=u;
		dfs(v[p],u);
	}
}

int main(){
	n=readint();
	for(int i=1;i<n;i++) addedge(readint(),readint());
	dep[1]=f[1]=0; dfs(1,-1);
	int maxa=0,x=0,y=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,dep[i])) x=i;
	dep[x]=f[x]=0; dfs(x,-1);
	maxa=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,dep[i])) y=i;
	vis[x]=vis[y]=1;
	int tmp=f[y];
	while(tmp!=x) vec.push_back(du[tmp]-1),vis[tmp]=1,tmp=f[tmp];
	for(int i=1;i<=n;i++) if(!vis[i]&&nxt[h[i]]) return printf("-1\n"),0;
	int tl=0,tr=vec.size()-1,fl=0;
	for(int i=0;i<vec.size();i++){
		if(vec[tl]>vec[tr]) fl=-1;
		else if(vec[tl]<vec[tr]) fl=1;
		tl++,tr--;
		if(fl!=0) break;
	}
	if(fl<0) reverse(vec.begin(),vec.end());
	ans[1]=1,ans[n]=n;
	int now=1;
	for(int i=0;i<vec.size();i++){
		for(int j=2;j<=vec[i];j++) ans[now+j-1]=now+j;
		ans[now+vec[i]]=now+1;
		now+=vec[i];
	}
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}
```