#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
int n,u,v,dep[maxn],point[2];
int s=0,p[2][maxn];
bool tag[maxn];
vector <int> to[maxn];
inline long long read(){
	long long x=0,f=1;
	char c;
	do{c=getchar();if(c=='-') f*=-1;}while(!isdigit(c));
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
void get_dep(int now,int fa,int &res){
	dep[now]=dep[fa]+1;
	res=dep[now]>dep[res]?now:res;
	int siz=to[now].size();
	for(int i=0;i<siz;i++){
		int v=to[now][i];
		if(v==fa) continue;
		get_dep(v,now,res);
	}
}
int Find_longpoint(int now){
	int res=0;
	get_dep(now,0,res);
	return res;
}
bool make_tag(int now,int fa,int target){
	int siz=to[now].size();
	bool ex=(now==target)?true:false;
	for(int i=0;i<siz;i++){
		int v=to[now][i];
		if(v==fa) continue;
		ex|=make_tag(v,now,target);
	}
	tag[now]=ex;
	return ex;
}
bool check_it(){
	int cnt=0;
	for(int i=1;i<=n;i++){if(tag[i]) cnt+=(to[i].size()-1);}
	return (cnt+2==n);
}
void get_permutation(int now,int fa,int node,int cur){
	int siz=to[now].size(),nut=cur,tto=0;
	for(int i=0;i<siz;i++){
		int v=to[now][i];
		if(v==fa) continue;
		if(tag[v]) tto=v;
		else{p[node][nut]=nut+1;nut++;}
	}
	p[node][nut]=cur;
	if(tto) get_permutation(tto,now,node,nut+1);
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		u=read();v=read();
		to[u].push_back(v);
		to[v].push_back(u);
	}
	point[0]=Find_longpoint(1);
	point[1]=Find_longpoint(point[0]);
	make_tag(point[0],0,point[1]);
	if(!check_it()){printf("-1\n");}
	else{
		get_permutation(point[0],0,0,1);
		get_permutation(point[1],0,1,1);
		for(int i=1;i<=n;i++){
			if(p[0][i]==p[1][i]) continue;
			if(p[0][i]>p[1][i]){s=1;break;}
			if(p[0][i]<p[1][i]){s=0;break;}
		}
		for(int i=1;i<=n;i++){printf("%d ",p[s][i]);}
		printf("\n");
	}
	return 0;
}
### Prompt

In cpp, your task is to solve 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>
using namespace std;
const int maxn=2e5;
int n,u,v,dep[maxn],point[2];
int s=0,p[2][maxn];
bool tag[maxn];
vector <int> to[maxn];
inline long long read(){
	long long x=0,f=1;
	char c;
	do{c=getchar();if(c=='-') f*=-1;}while(!isdigit(c));
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
void get_dep(int now,int fa,int &res){
	dep[now]=dep[fa]+1;
	res=dep[now]>dep[res]?now:res;
	int siz=to[now].size();
	for(int i=0;i<siz;i++){
		int v=to[now][i];
		if(v==fa) continue;
		get_dep(v,now,res);
	}
}
int Find_longpoint(int now){
	int res=0;
	get_dep(now,0,res);
	return res;
}
bool make_tag(int now,int fa,int target){
	int siz=to[now].size();
	bool ex=(now==target)?true:false;
	for(int i=0;i<siz;i++){
		int v=to[now][i];
		if(v==fa) continue;
		ex|=make_tag(v,now,target);
	}
	tag[now]=ex;
	return ex;
}
bool check_it(){
	int cnt=0;
	for(int i=1;i<=n;i++){if(tag[i]) cnt+=(to[i].size()-1);}
	return (cnt+2==n);
}
void get_permutation(int now,int fa,int node,int cur){
	int siz=to[now].size(),nut=cur,tto=0;
	for(int i=0;i<siz;i++){
		int v=to[now][i];
		if(v==fa) continue;
		if(tag[v]) tto=v;
		else{p[node][nut]=nut+1;nut++;}
	}
	p[node][nut]=cur;
	if(tto) get_permutation(tto,now,node,nut+1);
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		u=read();v=read();
		to[u].push_back(v);
		to[v].push_back(u);
	}
	point[0]=Find_longpoint(1);
	point[1]=Find_longpoint(point[0]);
	make_tag(point[0],0,point[1]);
	if(!check_it()){printf("-1\n");}
	else{
		get_permutation(point[0],0,0,1);
		get_permutation(point[1],0,1,1);
		for(int i=1;i<=n;i++){
			if(p[0][i]==p[1][i]) continue;
			if(p[0][i]>p[1][i]){s=1;break;}
			if(p[0][i]<p[1][i]){s=0;break;}
		}
		for(int i=1;i<=n;i++){printf("%d ",p[s][i]);}
		printf("\n");
	}
	return 0;
}
```