All problems

Ordering Categories Explicitly

mediumPythonSeabornorder

The Ravensworth Group sells its service in named sizes, and left to itself the chart arranges those sizes in whatever order they happened to appear in the file -- which puts Large before Small and makes the reader work. Each report therefore supplies the running order it wants. The caption quotes the figure for whichever size ends up on the right-hand end.

Task: Print the value of the size that comes last in the supplied order.

Input

The first line holds one integer n, the number of records, where 1 <= n <= 1000. Then come n lines, each holding a size label and a value separated by a single space. Each size label appears on exactly one line. The final line lists the size labels in the order the report wants them, separated by single spaces.

Output

One line holding the value belonging to the last label on that final line, rounded to 2 decimal places. Last means last in the supplied order, not last in the records above it.

Example:

Input:
3
Large 30
Small 10
Medium 20
Small Medium Large

Output:
30.00

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…