#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAX=100005;
const ll MOD=1000000007;
vector<int> conn[MAX];
int cnt[MAX],o1,o2,p[MAX],pt[MAX],n,chk[MAX],chk2[MAX],pt2[MAX],p2[MAX];
void bone(int x,int u){
    int t=conn[x].size()-cnt[x]+1;
    chk[x]=1;
    p[u]=u+t-1;
    for(int i=1;i<t;i++) p[u+i]=u+i-1;
    for(int i=0;i<conn[x].size();i++){
        if(cnt[conn[x][i]]!=0&&chk[conn[x][i]]==0) {
            bone(conn[x][i],u+t);
            return;
        }
    }
}
void bone2(int x,int u){
    int t=conn[x].size()-cnt[x]+1;
    chk2[x]=1;
    p2[u]=u+t-1;
    for(int i=1;i<t;i++) p2[u+i]=u+i-1;
    for(int i=0;i<conn[x].size();i++){
        if(cnt[conn[x][i]]!=0&&chk2[conn[x][i]]==0) {
            bone2(conn[x][i],u+t);
            return;
        }
    }
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++) {
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        conn[t1].push_back(t2);
        conn[t2].push_back(t1);
    }
    for(int i=1;i<=n;i++) cnt[i]=conn[i].size();
    for(int i=1;i<=n;i++) if(conn[i].size()==1&&cnt[conn[i][0]]>2){
        cnt[i]--,cnt[conn[i][0]]--;
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>=3){
            printf("-1\n");
            return 0;
        }
        if(cnt[i]==1){
            if(o1==0) o1=i;
            else o2=i;
        }
    }
    bone(o1,1);
    bone2(o2,1);
    for(int i=1;i<=n;i++) pt[p[i]]=i;
    for(int i=1;i<=n;i++) pt2[p2[i]]=i;
    int l;
    for(int i=1;i<=n;i++){
        if(pt[i]<pt2[i]) {l=0; break;}
        else if(pt2[i]<pt[i]) {l=1;break;}
    }
    //if(o2==0) l=0;
    if(l==0) for(int i=1;i<=n;i++)printf("%d ",pt[i]);
    else for(int i=1;i<=n;i++)printf("%d ",pt2[i]);
    printf("\n");
}


### 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<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAX=100005;
const ll MOD=1000000007;
vector<int> conn[MAX];
int cnt[MAX],o1,o2,p[MAX],pt[MAX],n,chk[MAX],chk2[MAX],pt2[MAX],p2[MAX];
void bone(int x,int u){
    int t=conn[x].size()-cnt[x]+1;
    chk[x]=1;
    p[u]=u+t-1;
    for(int i=1;i<t;i++) p[u+i]=u+i-1;
    for(int i=0;i<conn[x].size();i++){
        if(cnt[conn[x][i]]!=0&&chk[conn[x][i]]==0) {
            bone(conn[x][i],u+t);
            return;
        }
    }
}
void bone2(int x,int u){
    int t=conn[x].size()-cnt[x]+1;
    chk2[x]=1;
    p2[u]=u+t-1;
    for(int i=1;i<t;i++) p2[u+i]=u+i-1;
    for(int i=0;i<conn[x].size();i++){
        if(cnt[conn[x][i]]!=0&&chk2[conn[x][i]]==0) {
            bone2(conn[x][i],u+t);
            return;
        }
    }
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++) {
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        conn[t1].push_back(t2);
        conn[t2].push_back(t1);
    }
    for(int i=1;i<=n;i++) cnt[i]=conn[i].size();
    for(int i=1;i<=n;i++) if(conn[i].size()==1&&cnt[conn[i][0]]>2){
        cnt[i]--,cnt[conn[i][0]]--;
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>=3){
            printf("-1\n");
            return 0;
        }
        if(cnt[i]==1){
            if(o1==0) o1=i;
            else o2=i;
        }
    }
    bone(o1,1);
    bone2(o2,1);
    for(int i=1;i<=n;i++) pt[p[i]]=i;
    for(int i=1;i<=n;i++) pt2[p2[i]]=i;
    int l;
    for(int i=1;i<=n;i++){
        if(pt[i]<pt2[i]) {l=0; break;}
        else if(pt2[i]<pt[i]) {l=1;break;}
    }
    //if(o2==0) l=0;
    if(l==0) for(int i=1;i<=n;i++)printf("%d ",pt[i]);
    else for(int i=1;i<=n;i++)printf("%d ",pt2[i]);
    printf("\n");
}


```