#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000005
#define MOD 1000000007 
#define N 100005
#define M 1000000
#define LOG 20
#define KOK 300
#define EPS 0.0000001
using namespace std;

int mx,dia,n;
int sub[N],dad[N];
vector<int> v[N];

void dfs(int node,int ata,int dst) {

	dad[node]=ata;
	sub[node]=1;

	if(dst>mx) {

		mx=dst;
		dia=node;

	}

	for(auto x:v[node]) {

		if(x==ata) continue ;

		dfs(x,node,dst+1);

		sub[node]+=sub[x];

	}

}

vector<int> ans;
vector<int> cur;
int val;

void dfs2(int node,int ata) {

	int leaf=0;
	int non=0;

	for(int x:v[node]) {

		if(x==ata) continue ;

		leaf+=(sub[x]==1);
		non+=!(sub[x]==1);

	}

	if(non>1) return ;

	if(non) {

		int tut=++val;

		for(int i=1;i<=leaf;i++) {

			cur.pb(++val);

		}

		cur.pb(tut);

		for(int x:v[node]) {

			if(x==ata || sub[x]==1) continue ;

			dfs2(x,node);

		}
	
	}
	else {

		int tut=++val;

		for(int i=1;i<leaf;i++) {

			cur.pb(++val);

		}

		cur.pb(tut);
		cur.pb(++val);

		if(!sz(ans)) ans=cur;
		else umin(ans,cur);

	}

}

void solve(int node) {

	cur.clear();
	val=0;

	dfs(node,0,0);

	dfs2(node,0);

}

int main() {

	int root=1;

	scanf("%d",&n);

	for(int i=1;i<n;i++) {

		int x,y;

		scanf("%d %d",&x,&y);

		v[x].pb(y);
		v[y].pb(x);

		if(sz(v[x])>1) root=x;
		if(sz(v[y])>1) root=y;

	}

	vector<int> cd;

	mx=0;
	dfs(root,0,0);

	cd.pb(dia);

	mx=0;
	dfs(dia,0,0);

	cd.pb(dia);

	solve(cd[0]);
	solve(cd[1]);

	if(ans.empty()) printf("-1");
	else for(auto x:ans) printf("%d ",x);

}	
### Prompt

Create a solution in CPP for 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 st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000005
#define MOD 1000000007 
#define N 100005
#define M 1000000
#define LOG 20
#define KOK 300
#define EPS 0.0000001
using namespace std;

int mx,dia,n;
int sub[N],dad[N];
vector<int> v[N];

void dfs(int node,int ata,int dst) {

	dad[node]=ata;
	sub[node]=1;

	if(dst>mx) {

		mx=dst;
		dia=node;

	}

	for(auto x:v[node]) {

		if(x==ata) continue ;

		dfs(x,node,dst+1);

		sub[node]+=sub[x];

	}

}

vector<int> ans;
vector<int> cur;
int val;

void dfs2(int node,int ata) {

	int leaf=0;
	int non=0;

	for(int x:v[node]) {

		if(x==ata) continue ;

		leaf+=(sub[x]==1);
		non+=!(sub[x]==1);

	}

	if(non>1) return ;

	if(non) {

		int tut=++val;

		for(int i=1;i<=leaf;i++) {

			cur.pb(++val);

		}

		cur.pb(tut);

		for(int x:v[node]) {

			if(x==ata || sub[x]==1) continue ;

			dfs2(x,node);

		}
	
	}
	else {

		int tut=++val;

		for(int i=1;i<leaf;i++) {

			cur.pb(++val);

		}

		cur.pb(tut);
		cur.pb(++val);

		if(!sz(ans)) ans=cur;
		else umin(ans,cur);

	}

}

void solve(int node) {

	cur.clear();
	val=0;

	dfs(node,0,0);

	dfs2(node,0);

}

int main() {

	int root=1;

	scanf("%d",&n);

	for(int i=1;i<n;i++) {

		int x,y;

		scanf("%d %d",&x,&y);

		v[x].pb(y);
		v[y].pb(x);

		if(sz(v[x])>1) root=x;
		if(sz(v[y])>1) root=y;

	}

	vector<int> cd;

	mx=0;
	dfs(root,0,0);

	cd.pb(dia);

	mx=0;
	dfs(dia,0,0);

	cd.pb(dia);

	solve(cd[0]);
	solve(cd[1]);

	if(ans.empty()) printf("-1");
	else for(auto x:ans) printf("%d ",x);

}	
```