from collections import Counter

N = int(eval(input()))

src = [eval(input()) for i in range(N)]



ctr = Counter(src[0])

for s in src[1:]:

    ctr &= Counter(s)



ans = ''

for k,v in sorted(ctr.items()):

    ans += k*v

print(ans)
N = int(eval(input()))

S = [eval(input()) for i in range(N)]

from collections import Counter

ctr = Counter(S[0])

for s in S[1:]:

    ctr &= Counter(s)

ans = ''

for k,v in sorted(ctr.items()):

    ans += k * v

print(ans)
from collections import Counter

N = int(eval(input()))
src = [eval(input()) for i in range(N)]
ctr = Counter(src[0])
for s in src[1:]:
    ctr &= Counter(s)
ans = ""
for k, v in sorted(ctr.items()):
    ans += k * v
print(ans)

N = int(eval(input()))
S = [eval(input()) for i in range(N)]
from collections import Counter

ctr = Counter(S[0])
for s in S[1:]:
    ctr &= Counter(s)
ans = ""
for k, v in sorted(ctr.items()):
    ans += k * v
print(ans)

+N = int(eval(input())) +S = [eval(input()) for i in range(N)] -N = int(eval(input())) -src = [eval(input()) for i in range(N)] -ctr = Counter(src[0]) -for s in src[1:]: +ctr = Counter(S[0]) +for s in S[1:]: