#P1327. Finding the Owner

Finding the Owner

Finding the Owner

题目描述

image.png The picture above shows a note left by a programmer who found a bag for the owner, with a very clever two-way encryption: "I found a bag downstairs. Please contact me if you see it! My phone number: "1832834xxxx""1832834xxxx". He claimed that the first two "xx""xx" are "the 8th8th and 9th9th digits of your ID number", the next "x""x" is "the 5th5th digit of your ID number", and the last "x""x" is "the last digit of your ID number". Now given the programmer's complete mobile phone number and the ID numbers of a large group of people, please find the owner.

输入格式

Each input file contains one test case. The 1st1st line gives the 11digit11-digit phone number of the programmer, and the 2nd2nd line gives a positive integer nn (105)(≤10^5). Then nn lines follow, each contains an 18digit18-digit ID number. For the sake of privacy protection, those ID numbers are not real. It is only guaranteed that each ID is an 18digit18-digit number.

输出格式

Output in a line the ID number of the owner. It is guaranteed that the answer is unique.

样例 #1

样例输入 #1

18328349823
10
130124198703030914
412901197609212008
450703198308160035
412928194606180028
413921194910290412
240902197104212813
371521198711123153
140113196511250117
622922200306127013
342520198912300017

样例输出 #1

371521198711123153