10
4 2
7 4
2 6
2 5
4 8
10 3
2 9
9 1
5 10
 10
5 10
7 8
8 3
2 6
3 2
9 7
4 5
10 1
6 4
 4
4 1
4 3
4 2
 3
3 1
1 2
 9
1 2
1 3
1 4
1 5
1 6
6 7
6 8
8 9
 5
1 5
2 3
2 4
1 2
 8
6 1
4 7
4 8
8 5
7 6
4 3
4 2
 7
5 6
5 7
5 1
7 4
6 3
3 2
 3
1 3
3 2
 2
1 2
 5
5 4
4 3
3 1
5 2
 6
1 6
3 1
6 4
5 3
2 5
 11
8 9
2 7
1 11
3 2
9 1
8 5
8 6
5 4
4 10
8 3
 11
11 9
6 7
7 1
8 11
5 6
3 5
9 3
10 8
2 4
4 10
 12
12 6
6 7
8 11
4 8
10 4
12 3
2 10
6 2
12 9
4 1
9 5

-1
 9
 1
 1
 3
 3
 -1
 -1
 1
 1
 1
 5
 1
 5
 -1

//package e_contest_9;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class treeFolding {
	static ArrayList<Integer> adjList[];
public static void main(String[] args) throws IOException{
	Scanner sc= new Scanner(System.in);
	int n =sc.nextInt();
	adjList =new ArrayList[n];
	for (int i = 0; i < adjList.length; i++) {
		adjList[i] = new ArrayList<Integer>();
	}
	int max = 0;
	for (int i = 0; i < n-1; i++) {
		int one = sc.nextInt()-1;
		int two =sc.nextInt()-1;
		adjList[one].add(two);
		adjList[two].add(one);
		max = Math.max(max,Math.max(adjList[one].size(),adjList[two].size()));
	}
	
	if(max>3) {
		System.out.println("-1");
	}else {
		boolean poss =true;
		Queue<Integer> q = new LinkedList<Integer>();
		Queue<Integer> qThree = new LinkedList<Integer>();
		for (int i = 0; i < adjList.length; i++) {
			if(adjList[i].size()==1)
				q.add(i);
			if(adjList[i].size()==3)
				qThree.add(i);
		}
//		System.out.println(q.toString());
		int [] endSize = new int[n];
		int ans = 0;
		while(!q.isEmpty()) {
		
			int cur = q.remove();
			int parent = adjList[cur].get(0);
//			System.out.println((cur+1)+" "+(1+parent));
			if(endSize[parent]!=0) {
				int total = endSize[parent]+1;
				while(total%2==1) {
					total-=total/2;
				}
			System.out.println(total-1);
			}else {
			int size = 1;
			while(true) {
//				System.out.println((cur+1)+" "+(1+parent));
				if(adjList[parent].size()==3) {
					endSize[cur] = size;
					break;
				}
				if(adjList[parent].size()==1) {
					endSize[cur] = size;
					break;
				}
				int idx = 0;
				for (int i = 0; i < adjList[parent].size(); i++) {
					if(adjList[parent].get(i)!=cur)
						idx = i;
				}
				cur = parent;
				parent = adjList[parent].get(idx);
				size++;
			}
			}
		}
		
		boolean found = true;
		int[] counter =new int[n];
		int time=0;//
//		System.out.println(Arrays.toString(endSize));
		while(true&&qThree.size()>0) {
			
//			System.out.println(qThree.size());
//		System.out.println(Arrays.toString(endSize));
			
//			int counterBefore = qThree.size();
			if(qThree.size()==1) {
				int center = qThree.remove();
				int one = endSize[adjList[center].get(0)];
				int two = endSize[adjList[center].get(1)];
				int three = endSize[adjList[center].get(2)];
				if(one==two) {
					int total = 1+one+three;
					while(total%2==1) {
						total-=total/2;
					}
					System.out.println(total-1);
				}else if(one==three||two==three) {
					int total = 1+one+two;
					while(total%2==1) {
						total-=total/2;
					}
					System.out.println(total-1);
				}else {
					found = false;
				}
				if(!found)
					System.out.println(-1);
				break;
			}
			int center = qThree.remove();
			int one = endSize[adjList[center].get(0)];
			int two = endSize[adjList[center].get(1)];
			int three = endSize[adjList[center].get(2)];
			if(one==two||one==three) {
				int size = one+1;
				int idx = one==three?1:2;
				int parent = adjList[center].get(idx);
				int child = center;
				while(adjList[parent].size()==2) {
					idx = adjList[parent].get(0)==child?1:0;
					child =parent;
					parent= adjList[parent].get(idx);
					size++;
				}
				endSize[child]=size;
			}else if(two==three) {
				int size = three+1;
				int parent = adjList[center].get(0);
				int child = center;
				while(adjList[parent].size()==2) {
					int idx = adjList[parent].get(0)==child?1:0;
					child =parent;
					parent= adjList[parent].get(idx);
					size++;
				}
				endSize[child]=size;
			}else
				q.add(center);
			time++;
			if(counter[center]+q.size()==3)
				break;
			counter[center]=time;
		}//1 2 3
		if(qThree.size()>0)
			System.out.println(-1);
		
	}
	
}
static class Scanner 
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException 
	{
		while (st == null || !st.hasMoreTokens()) 
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}
	
	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}
	
	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}
	
	public boolean ready() throws IOException {return br.ready();}


}


}
