#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < ll , ll > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

vector < int > V[N];
int T[N],T2[N],W[N],A[N],n,i,j,x,y,t,t2,h,a;

int main(){
    cin >> n;
    if(n == 2) { cout << "1 2"; return 0; }
    for(i=2;i<=n;i++){
        cin >> x >> y;
        V[x].pb(y); V[y].pb(x);
        W[x]++; W[y]++;
    }
    for(i=1;i<=n;i++){
        if(V[i].size() == 1) { W[i] = 0; W[ V[i][0] ]--; }
    }

    for(i=1;i<=n;i++)
        if(W[i] > 2){
            cout << -1;
            return 0;
        }

    for(i=1;i<=n;i++){
        if(W[i] == 1){
            x = i;
            for(; W[x] ; x = y){
                A[++a] = x;
                W[x] = 0;
                y = 0;
                for(j=0;j<V[x].size();j++)
                    if(W[ V[x][j] ])
                        y = V[x][j];
            }
            break;
        }
    }

    if(a == 0){
        for(i=1;i<=n;i++)
            if(V[i].size() > 1)
                A[++a] = i;
    }

    T[++t] = 1;
    for(i=1;i<=a;i++){
        x = A[i];
        x = j = V[x].size()-2;
        for(;j--; t++)
            T[t+1] = t+2;
        T[t+1] = t+1-x; t++;
    }

    T2[++t2] = 1;
    for(i=a; i ;i--){
        x = A[i];
        x = j = V[x].size()-2;
        for(;j--; t2++)
            T2[t2+1] = t2+2;
        T2[t2+1] = t2+1-x; t2++;
    }

    for(i=1;i<n;i++){
        if(h == -1) cout << T[i] << " ";
        if(h == 1) cout << T2[i] << " ";
        if(h == 0){
            if(T[i] == T2[i]) cout << T[i] << " ";
            if(T[i] < T2[i]) { h = -1; i--; }
            if(T2[i] < T[i]) { h = 1; i--; }
        }
    }

    cout << n << endl;
    return 0;
}
### Prompt

Generate 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;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < ll , ll > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

vector < int > V[N];
int T[N],T2[N],W[N],A[N],n,i,j,x,y,t,t2,h,a;

int main(){
    cin >> n;
    if(n == 2) { cout << "1 2"; return 0; }
    for(i=2;i<=n;i++){
        cin >> x >> y;
        V[x].pb(y); V[y].pb(x);
        W[x]++; W[y]++;
    }
    for(i=1;i<=n;i++){
        if(V[i].size() == 1) { W[i] = 0; W[ V[i][0] ]--; }
    }

    for(i=1;i<=n;i++)
        if(W[i] > 2){
            cout << -1;
            return 0;
        }

    for(i=1;i<=n;i++){
        if(W[i] == 1){
            x = i;
            for(; W[x] ; x = y){
                A[++a] = x;
                W[x] = 0;
                y = 0;
                for(j=0;j<V[x].size();j++)
                    if(W[ V[x][j] ])
                        y = V[x][j];
            }
            break;
        }
    }

    if(a == 0){
        for(i=1;i<=n;i++)
            if(V[i].size() > 1)
                A[++a] = i;
    }

    T[++t] = 1;
    for(i=1;i<=a;i++){
        x = A[i];
        x = j = V[x].size()-2;
        for(;j--; t++)
            T[t+1] = t+2;
        T[t+1] = t+1-x; t++;
    }

    T2[++t2] = 1;
    for(i=a; i ;i--){
        x = A[i];
        x = j = V[x].size()-2;
        for(;j--; t2++)
            T2[t2+1] = t2+2;
        T2[t2+1] = t2+1-x; t2++;
    }

    for(i=1;i<n;i++){
        if(h == -1) cout << T[i] << " ";
        if(h == 1) cout << T2[i] << " ";
        if(h == 0){
            if(T[i] == T2[i]) cout << T[i] << " ";
            if(T[i] < T2[i]) { h = -1; i--; }
            if(T2[i] < T[i]) { h = 1; i--; }
        }
    }

    cout << n << endl;
    return 0;
}
```