cho.sh
Notes
Loading...

Building a Tree Model

Time limit

2s

Memory limit

128 MB

Problem

A toy company wants to build a model of a tree using pieces of string. A tree is a connected graph with no cycles. In this problem, the vertices and edges of the graph are called nodes and links.

Each node is represented by a knot tied on the string. A knot may be tied at the middle or end of one string, or it may be a point where several strings are tied together. Each link is represented by a string segment between two knots. One string may continue along a path of the tree, but it cannot branch.

For technical reasons, the production cost depends on the number of strings used and on the length of the longest string among them. Every link has length 1, and the length of string used to make knots is ignored.

Given the structure of the tree, first find the minimum number of strings needed to build the model. Then, among all constructions using that minimum number of strings, find the minimum possible length of the longest string.

Input

The first line contains the number of nodes n, where 2 <= n <= 10000.

Each of the next n - 1 lines contains two positive integers describing one link. The two integers are the numbers of the two nodes connected by that link. Node numbers are exactly the integers from 1 through n.

Output

Print two integers on one line: the minimum number of strings needed, and the minimum possible length of the longest string when that many strings are used.

Hint

No additional hint is provided.