import os
f = lambda s,x:os.path.commonprefix([t for t in x if s<=t<s+'ÿ'])or s

for _ in range(7):
	print f(*input())