players = dict()
count = int(input())
for i in range(count):
first_alpha = input()[0]
if players.get(first_alpha):
players[first_alpha] += 1
else:
players[first_alpha] = 1
# print(players)
rlt = ''
for key in players:
if players[key] >= 5:
rlt += key
if rlt:
rlt = sorted(rlt)
print(''.join(rlt))
else:
print('PREDAJA')
players = dict()
count = int(input())
for i in range(count):
first_alpha = input()[0]
if players.get(first_alpha):
players[first_alpha] += 1
else:
players[first_alpha] = 1
# print(players)
rlt = ''
for key in players:
if players[key] >= 5:
rlt += key
if rlt:
rlt = sorted(rlt)
print(''.join(rlt))
else:
print('PREDAJA')