//qwq
#include<iostream>
#include<cstdio>
#include<cstring>
#define add(x,y) (ct(x,y),ct(y,x))
#define CT const int&
using namespace std;
const int MAXN = 4e5 + 7;
int n, T, ccnt;
int q[MAXN], home[MAXN], p[MAXN], fa[MAXN],  dep[MAXN],
	deg[MAXN], vis[MAXN], nxt[MAXN], to[MAXN], d[MAXN];

inline void ct(CT u, CT v) {
	++ccnt;
	to[ccnt] = v;
	nxt[ccnt] = home[u];
	home[u] = ccnt;

}

inline int dfs(int u, int F) {
	int res = u, s;
	fa[u] = F;
	dep[u] = dep[F] + 1;
	for(int i = home[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v != F) {
			s = dfs(v, u);
			if(dep[res] < dep[s])res = s;
			//长链剖分/jk
		}
	}
	return res;
}

int main() {
	scanf("%d", &n);
	int rt1, rt2, num, u, v;
	for(int i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v);
		add(u, v);
	}
	rt1 = dfs(1, 0);
	fa[rt1] = 0;
	dep[rt1] = 0;
	rt2 = dfs(rt1, 0);
	// printf("%d %d\n", rt1, rt2);
	for(; rt2; rt2 = fa[rt2])vis[rt2] = 1, d[++T] = rt2;
	// printf("%d \n", T);
	for(int u = 1; u <= n; ++u) {
		if(vis[u])continue;
		bool ans = 0;
		for(int i = home[u]; i; i = nxt[i]) {
			int v = to[i];
			if(vis[v]) {
				deg[v]++;
				ans = 1;
				break;
			}
		}
		if(!ans)return puts("-1"), 0;
	}
	num = 0;
	for(int i = 1; i <= T; ++i) {
		for(int j = 1; j <= deg[d[i]]; ++j) {
			p[num + j] = num + j + 1;
		}
		p[num + deg[d[i]] + 1] = num + 1;
		num += deg[d[i]] + 1;
	}
	num = 0;
	for(int i = T; i >= 1; --i) {
		for(int j = 1; j <= deg[d[i]]; ++j) {
			q[num + j] = num + j + 1;
		}
		q[num + deg[d[i]] + 1] = num + 1;
		num += deg[d[i]] + 1;
	}
	for(int i = 1; i <= n; ++i) {
		if(p[i] != q[i]) {
			if(p[i] < q[i]) {
				for(int j = 1; j <= n; ++j) {
					printf("%d ", p[j]);
				}					puts("");

				return 0;
			} else {
				for(int j = 1; j <= n; ++j) {
					printf("%d ", q[j]);
				}				puts("");

				return 0;
			}
		}
	}
	for(int j = 1; j <= n; ++j) {
		printf("%d ", p[j]);
	}		puts("");

	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
//qwq
#include<iostream>
#include<cstdio>
#include<cstring>
#define add(x,y) (ct(x,y),ct(y,x))
#define CT const int&
using namespace std;
const int MAXN = 4e5 + 7;
int n, T, ccnt;
int q[MAXN], home[MAXN], p[MAXN], fa[MAXN],  dep[MAXN],
	deg[MAXN], vis[MAXN], nxt[MAXN], to[MAXN], d[MAXN];

inline void ct(CT u, CT v) {
	++ccnt;
	to[ccnt] = v;
	nxt[ccnt] = home[u];
	home[u] = ccnt;

}

inline int dfs(int u, int F) {
	int res = u, s;
	fa[u] = F;
	dep[u] = dep[F] + 1;
	for(int i = home[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v != F) {
			s = dfs(v, u);
			if(dep[res] < dep[s])res = s;
			//长链剖分/jk
		}
	}
	return res;
}

int main() {
	scanf("%d", &n);
	int rt1, rt2, num, u, v;
	for(int i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v);
		add(u, v);
	}
	rt1 = dfs(1, 0);
	fa[rt1] = 0;
	dep[rt1] = 0;
	rt2 = dfs(rt1, 0);
	// printf("%d %d\n", rt1, rt2);
	for(; rt2; rt2 = fa[rt2])vis[rt2] = 1, d[++T] = rt2;
	// printf("%d \n", T);
	for(int u = 1; u <= n; ++u) {
		if(vis[u])continue;
		bool ans = 0;
		for(int i = home[u]; i; i = nxt[i]) {
			int v = to[i];
			if(vis[v]) {
				deg[v]++;
				ans = 1;
				break;
			}
		}
		if(!ans)return puts("-1"), 0;
	}
	num = 0;
	for(int i = 1; i <= T; ++i) {
		for(int j = 1; j <= deg[d[i]]; ++j) {
			p[num + j] = num + j + 1;
		}
		p[num + deg[d[i]] + 1] = num + 1;
		num += deg[d[i]] + 1;
	}
	num = 0;
	for(int i = T; i >= 1; --i) {
		for(int j = 1; j <= deg[d[i]]; ++j) {
			q[num + j] = num + j + 1;
		}
		q[num + deg[d[i]] + 1] = num + 1;
		num += deg[d[i]] + 1;
	}
	for(int i = 1; i <= n; ++i) {
		if(p[i] != q[i]) {
			if(p[i] < q[i]) {
				for(int j = 1; j <= n; ++j) {
					printf("%d ", p[j]);
				}					puts("");

				return 0;
			} else {
				for(int j = 1; j <= n; ++j) {
					printf("%d ", q[j]);
				}				puts("");

				return 0;
			}
		}
	}
	for(int j = 1; j <= n; ++j) {
		printf("%d ", p[j]);
	}		puts("");

	return 0;
}
```