#include <stdio.h>
#include <algorithm>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x1f3f3f3f3f3f3f3f;
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)

const int MX = 200005;

vector<int> G[MX];
vector<int> H[MX];
vector<int> P, ans;
int sz = 0;

void dfs(int x, int b = -1){
	int nxt = -1;
	if(H[x].size() == 2) nxt = H[x][0] ^ H[x][1] ^ b;
	if(b == -1 && H[x].size() == 1) nxt = H[x][0];
	int cur = ++sz;
	for(int c : G[x]){
		if(nxt == c || c == b) continue;
		P.push_back(++sz);
	}
	P.push_back(cur);
	if(nxt != -1) dfs(nxt, x);
}

int main()
{
	int N;
	scanf("%d", &N);
	if(N == 2) return !printf("1 2\n");
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i = 1; i <= N; i++){
		if(G[i].size() == 1) continue;
		for(int c : G[i]){
			if(G[c].size() == 1) continue;
			H[i].push_back(c);
		}
	}
	vector<int> st;
	for(int i = 1; i <= N; i++){
		if(H[i].size() >= 3) return !printf("-1\n");
		if(H[i].size() == 1) st.push_back(i);
	}
	if(st.size() > 2) return !printf("-1\n");
	if(st.size() == 0){
		printf("1 ");
		for(int i = 2; i < N-1; i++) printf("%d ", i+1);
		printf("2 %d\n", N);
		return 0;
	}

	for(int &c : st){
		for(int d : G[c]){
			if(G[d].size() == 1){
				H[c].push_back(d);
				H[d].push_back(c);
				c = d;
				break;
			}
		}
	}

	for(int c : st){
		sz = 0; dfs(c);
		if(ans.empty() || ans > P) ans = P;
		P.clear();
	}
	for(int c : ans) printf("%d ", c); puts("");
}

### Prompt

Develop a solution in cpp to the problem described below:

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 <stdio.h>
#include <algorithm>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x1f3f3f3f3f3f3f3f;
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)

const int MX = 200005;

vector<int> G[MX];
vector<int> H[MX];
vector<int> P, ans;
int sz = 0;

void dfs(int x, int b = -1){
	int nxt = -1;
	if(H[x].size() == 2) nxt = H[x][0] ^ H[x][1] ^ b;
	if(b == -1 && H[x].size() == 1) nxt = H[x][0];
	int cur = ++sz;
	for(int c : G[x]){
		if(nxt == c || c == b) continue;
		P.push_back(++sz);
	}
	P.push_back(cur);
	if(nxt != -1) dfs(nxt, x);
}

int main()
{
	int N;
	scanf("%d", &N);
	if(N == 2) return !printf("1 2\n");
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i = 1; i <= N; i++){
		if(G[i].size() == 1) continue;
		for(int c : G[i]){
			if(G[c].size() == 1) continue;
			H[i].push_back(c);
		}
	}
	vector<int> st;
	for(int i = 1; i <= N; i++){
		if(H[i].size() >= 3) return !printf("-1\n");
		if(H[i].size() == 1) st.push_back(i);
	}
	if(st.size() > 2) return !printf("-1\n");
	if(st.size() == 0){
		printf("1 ");
		for(int i = 2; i < N-1; i++) printf("%d ", i+1);
		printf("2 %d\n", N);
		return 0;
	}

	for(int &c : st){
		for(int d : G[c]){
			if(G[d].size() == 1){
				H[c].push_back(d);
				H[d].push_back(c);
				c = d;
				break;
			}
		}
	}

	for(int c : st){
		sz = 0; dfs(c);
		if(ans.empty() || ans > P) ans = P;
		P.clear();
	}
	for(int c : ans) printf("%d ", c); puts("");
}

```