Under construction

Still being built. Things may change

Waiting Line at the Cafeteria Entrance

Interview

Time limit0.1sMemory limit512 MB

Summary
Simulate a cafeteria entrance queue and report the peak line length with the back student's number, choosing the smallest number on ties.
Level

Easy3 of 10

Topics
Queue, Simulation
Solved
No attempts yet

Problem

Several students are running toward the school cafeteria to eat. A student who reaches the cafeteria waits in a line at the entrance. A student who arrives earlier stands closer to the front of the line than a student who arrives later. Meals are prepared one portion at a time. When a portion is ready, the student at the front of the line enters the cafeteria and starts eating. A student who starts eating always finishes the meal.

You are given AA, which stores nn pieces of information about students arriving at the cafeteria and meals becoming ready. Process the 1st through nn-th pieces of information in order. Then output the number of students waiting in the entrance line at the moment that count was largest, along with the number of the student at the back of the line at that moment.

Each of the nn pieces of information in AA is one of the following two types.

  • 1 aa: A student with the positive integer number aa arrives at the cafeteria and joins the back of the entrance line.
  • 2: A meal portion is ready, and the student at the front of the entrance line starts eating.

Whenever a meal portion is ready, there is always a student waiting in the line. A student who is waiting in the line when no meal is ready does not eat.

Input

The first line contains nn. Each of the following nn lines contains one piece of information, which is either type 1 or type 2.

Output

Process the 1st through nn-th pieces of information in order. Then print two numbers separated by a space: the largest number of students waiting in the entrance line at any moment, and the number of the student at the back of the line at the moment that maximum occurred. If the maximum occurs more than once, print the case where the student at the back of the line has the smallest number.

Constraints

1 ≤\leq nn ≤\leq 100,000

AA contains only type 1 and type 2 pieces of information.

1 ≤\leq aa ≤\leq nn, and all positive integers aa are distinct.

Examples1

  1. Example 1

    Input
    5
    1 2
    1 1
    2
    1 3
    2
    
    Expected output
    2 1