#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 100005;

int n;
struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot;
int d[N];

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

int dis[N],lst[N];
bool vis[N];
int key[N];

void getdis(int x){
	vis[x]=1;
	for(int p=h[x];p;p=e[p].nxt)
	if (!vis[e[p].x]){
		dis[e[p].x]=dis[x]+1;
		lst[e[p].x]=x;
		getdis(e[p].x);
	}
}

int ans1[N],ans2[N];

int main(){
	//freopen("data.in","r",stdin);
	n=get();
	fo(i,2,n){
		int x=get(),y=get();
		inse(x,y),inse(y,x);
		d[x]++,d[y]++;
	}
	getdis(1);
	int val=0,w=1;
	fo(i,2,n)
	if (val<dis[i])w=i,val=dis[i];
	fo(i,1,n)lst[i]=dis[i]=0,vis[i]=0;
	getdis(w);
	val=0;
	int t=w;
	fo(i,1,n)
	if (val<dis[i])t=i,val=dis[i];
	int x=w,y=t;
	int k=0;
	for(int now=y;now;now=lst[now])key[++k]=now;
	fo(i,2,k-1)d[key[i]]-=2;
	d[x]--,d[y]--;
	int pre=1;
	ans1[1]=1;ans1[n]=n;
	fo(i,2,k-1){
		fo(x,pre+2,pre+d[key[i]]+1)ans1[x-1]=x;
		ans1[pre+d[key[i]]+1]=pre+1;
		pre=pre+d[key[i]]+1;
	}
	if (pre!=n-1)return printf("-1\n"),0;
	ans2[1]=1;ans2[n]=n;
	pre=1;
	fd(i,k-1,2){
		fo(x,pre+2,pre+d[key[i]]+1)ans2[x-1]=x;
		ans2[pre+d[key[i]]+1]=pre+1;
		pre=pre+d[key[i]]+1;
	}
	bool pd=1;
	fo(i,1,n)
	if (ans1[i]!=ans2[i]){
		pd=(ans1[i]<ans2[i]);
		break;
	}
	if (pd)fo(i,1,n)printf("%d ",ans1[i]);
	else fo(i,1,n)printf("%d ",ans2[i]);
	return 0;
}
### Prompt

Please formulate 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<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 100005;

int n;
struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot;
int d[N];

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

int dis[N],lst[N];
bool vis[N];
int key[N];

void getdis(int x){
	vis[x]=1;
	for(int p=h[x];p;p=e[p].nxt)
	if (!vis[e[p].x]){
		dis[e[p].x]=dis[x]+1;
		lst[e[p].x]=x;
		getdis(e[p].x);
	}
}

int ans1[N],ans2[N];

int main(){
	//freopen("data.in","r",stdin);
	n=get();
	fo(i,2,n){
		int x=get(),y=get();
		inse(x,y),inse(y,x);
		d[x]++,d[y]++;
	}
	getdis(1);
	int val=0,w=1;
	fo(i,2,n)
	if (val<dis[i])w=i,val=dis[i];
	fo(i,1,n)lst[i]=dis[i]=0,vis[i]=0;
	getdis(w);
	val=0;
	int t=w;
	fo(i,1,n)
	if (val<dis[i])t=i,val=dis[i];
	int x=w,y=t;
	int k=0;
	for(int now=y;now;now=lst[now])key[++k]=now;
	fo(i,2,k-1)d[key[i]]-=2;
	d[x]--,d[y]--;
	int pre=1;
	ans1[1]=1;ans1[n]=n;
	fo(i,2,k-1){
		fo(x,pre+2,pre+d[key[i]]+1)ans1[x-1]=x;
		ans1[pre+d[key[i]]+1]=pre+1;
		pre=pre+d[key[i]]+1;
	}
	if (pre!=n-1)return printf("-1\n"),0;
	ans2[1]=1;ans2[n]=n;
	pre=1;
	fd(i,k-1,2){
		fo(x,pre+2,pre+d[key[i]]+1)ans2[x-1]=x;
		ans2[pre+d[key[i]]+1]=pre+1;
		pre=pre+d[key[i]]+1;
	}
	bool pd=1;
	fo(i,1,n)
	if (ans1[i]!=ans2[i]){
		pd=(ans1[i]<ans2[i]);
		break;
	}
	if (pd)fo(i,1,n)printf("%d ",ans1[i]);
	else fo(i,1,n)printf("%d ",ans2[i]);
	return 0;
}
```