n = int(input())
m = {len(s): s for s in input().split()}
x = input()
for v in range(len(x), -1, -1):
    if v in m:
        print(m[v])
        break

f63e6adc7d0f9c0893b87253c6616be6819dfce4
<mask token>

<mask token>
for v in range(len(x), -1, -1):
    if v in m:
        print(m[v])
        break

n = int(input())
m = {len(s): s for s in input().split()}
x = input()
for v in range(len(x), -1, -1):
    if v in m:
        print(m[v])
        break
