H. Hierarchy
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You have joined a large corporation.

The corporation is divided into several companies, each managed by a CEO.

All employees of the corporation, except for the CEOs, have exactly one direct supervisor.

You are given an array b — the indexes of the direct supervisors for each employee of the company.

Output the index of the CEO who has the largest number of employees in the company, as well as that number itself.

Input

The first line contains an integer n (1 ≤ n ≤ 105) — the number of people in the company.

The second line contains n integers bi (0 ≤ bi ≤ n), where bi — the index of the direct supervisor of the i-th employee. If bi = 0, then the i-th employee is the CEO.

It is guaranteed that the described hierarchy is correct — if employee bi is the direct supervisor of employee i, then employee i is neither directly nor indirectly a supervisor of employee bi.

Output

In the first line, output two integers — the index of the CEO with the largest number of employees in the company and that number itself.

If there are multiple answers with the largest number of employees, output any.

Example
Input
15
6 0 0 15 13 2 15 14 13 3 12 0 12 2 11
Output
12 8
Note

First test case

  • The CEO with index 2 manages a company with employees 6, 14, 1, and 8 — a total of 5 people.
  • The CEO with index 3 manages a company with employee 10 — a total of 2 people.
  • The CEO with index 12 manages a company with all the other employees — a total of 8 people.