QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#11875. Strings

统计

String-Toys joint-stock company has asked you for help in solving the following problem. They want to manufacture models of connected acyclic graphs made of string.

Each graph consists of vertices and a certain number of edges joining distinct vertices. Each vertex can be joined to many other vertices. A graph is connected and acyclic, if every vertex can be reached from every other vertex by travelling along the edges and furthermore there is a unique way of doing so without turning back.

Graphs' vertices are to be modelled by nodes knotted on bits of string, while edges by the bits of string themselves between the nodes. Each node can be either a knot on a single bit of string or many bits knotted at one point. Due to technical reasons cost of production depends on the number of string bits used in making a model and length of the longest bit. (Each edge has length of 1. Length of string used to making a knot is negligible.)

You are to write a programme that:

  • reads from the standard input the description of a connected acyclic graph to be modelled,
  • calculates:
  • the minimal number of string bits necessary to making the model,
  • assuming that the number of string bit is minimal, the minimal length of the longest string bit needed to making the model.
  • writes the obtained numbers to the standard output.

Input

The first line contains one positive integer $n$ - the number of vertices in the graph, $2 ≤ n ≤ 10\,000$. Vertices are numbered from $1$ to $n$. The following $n-1$ lines contain descriptions of edges, one per line. Each of these lines contains a pair of integers $a$ and $b$ separated by a single space, $1 ≤ a,b ≤ n$, $a \ne b$. Such pair represents an edge joining vertices $a$ and $b$.

Output

Your programme should write two integers $k$ and $l$ separated by a single space in the first line of the output: $k$ should be the minimal number of string bits required to make the graph's model, while $l$ should be the minimal length of the longest string bit (assuming that $k$ string bits are used).

Example

Input

9
7 8
4 5
5 6
1 2
3 2
9 8
2 5
5 8

Output

4 2
problem_11875_1.gif
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.