402176: GYM100687 B Bad Printer (B)

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Bad Printer (B)time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Since some IDs were not readable, Dr. Khamis posted the hardcopy of the grades for the students and asked each student with a non-readable ID to tell him which ID and grade are his.

One of the students did not do well in the exam and thought of tricking Dr. Khamis in order to get a higher grade. However, Dr. Khamis is not easy to trick!

Given the ID of the student and a sequence of IDs and grades, where each ID contains at most one question mark. Your task is to find the maximum grade that the student can claim without Dr. Khamis noticing that he is not honest.

Input

The first line of the input contains an integer N (1 ≤ N ≤ 15), which represents the number of student IDs and grades that will follow, followed by the ID of the student.

Each of the following N lines contains an ID (20110000 ≤ ID ≤ 20159999) and a grade G (0 ≤ G ≤ 100) separated by a space. Each ID contains at most one question mark.

Without the question marks, no two students in the class have the same ID, and all their IDs are in the given range.

Output

Print the maximum grade the student can claim without Dr. Khamis noticing that he is dishonest.

ExamplesInput
4 20121234
201212?4 64
20121235 93
2012123? 87
2012?234 75
Output
87

加入题单

算法标签: