All problems

Controlling Bar Order Explicitly

mediumPythonSeabornorder

Tidewater Foods charts monthly volumes, and the months arrive from the warehouse system in whatever order the export happened to produce. A chart with March before January is worse than no chart, so the caller supplies the sequence the bars must appear in. The caption quotes the figure for the leftmost bar, since that is where a reader starts.

Task: Print the figure for the month that appears leftmost.

Input

The first line holds one integer n, the number of months. Each of the next n lines holds a month name and its figure, separated by a single space. After those, one final line holds the month names again in the order the bars must appear, separated by single spaces.

Output

One line holding the figure belonging to the FIRST month named on that final line, with exactly two decimal places. The order the months were read in has no bearing on the answer.

Example:

Input:
3
Mar 30
Jan 10
Feb 20
Jan Feb Mar

Output:
10.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…