cswork / OAOpen practice workspace

DatabricksOA #19

Goto Largest Bucket

Estimated EasyJudge-ready

Topics (AI-labelled)HashingSimulation

Process the commands in order: goto name switches to that bucket (creating an empty bucket if it does not exist); create name creates a file with that name in the current bucket. File names within the same bucket are unique, so creating a duplicate does not increase the file count. Return the name of the bucket with the most files; a tie is guaranteed not to occur.

Standard input/output and this site's supplementary ranges follow this problem's description.

Input

The first line contains the number of commands q (2≤q≤50000), followed by q lines of commands. name is a single token of 1..40 ASCII letters, digits, underscores, or hyphens. The first command is goto, and there is at least one create.

Output

Output the name of the bucket with the unique maximum number of files.

Example 1

Input:

9
goto bucketA
create fileA
create fileB
create fileA
goto bucketB
goto bucketC
create fileA
create fileB
create fileC

Output:

bucketC

Example 2

Input:

7
goto a
create x
goto b
create x
create y
goto c
create z

Output:

b

Example 3

Input:

2
goto solo
create a

Output:

solo

Editorial

Loading solution…