Problem A: Leaves [Easy]

## Problem A: Leaves [Easy]

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 689  Solved: 240
[Submit][Status][Web Board]

## Description

Write a program to print all the leaves of the given tree, numbered from 1 to N.  The root of the tree is node 1.

## Input

The first line will be an integer T (1≤T≤10), which is the number of test cases.

For each test data:

The first line contains an integer N (2N≤10^4) — the number of the nodes.

Each of the next N - 1 lines contain two integers a and b, which means there is an edge between node a and b (1≤a, b≤N).

## Output

For each case please, print all the leaves of the given tree, in ascending order.

For the tree has multiple leaf nodes, there is a blank between two leaf nodes, and ‘\n’ at the end of each line.

## Sample Input

1
4
1 2
2 3
3 4


## Sample Output

4


[Submit][Status]