n = int(eval(input()))



d = {}



for k in range(97, 97+26):

  d[chr(k)] = 51

  

for i in range(n):

  s = str(eval(input()))

  for j in range(97,97+26):

    d[chr(j)] = min(d[chr(j)], s.count(chr(j)))



ans = ''

for k, v in list(d.items()):

  ans += k*v

print((''.join(sorted(ans))))
n = int(eval(input()))

d = {}

for i in range(26):

    c = chr(i+ord('a'))

    d[c] = 10**18



for i in range(n):

    s = str(eval(input()))

    de = {}

    for i in range(26):

        c = chr(i+ord('a'))

        de[c] = 0

    for j in range(len(s)):

        if s[j] not in de:

            de[s[j]] = 1

        else:

            de[s[j]] += 1

    for k, v in list(de.items()):

        d[k] = min(d[k], de[k])



d = sorted(d.items())

#print(d)

ans = ''

for k, v in d:

    ans += k*v

print(ans)

n = int(eval(input()))
d = {}
for k in range(97, 97 + 26):
    d[chr(k)] = 51
for i in range(n):
    s = str(eval(input()))
    for j in range(97, 97 + 26):
        d[chr(j)] = min(d[chr(j)], s.count(chr(j)))
ans = ""
for k, v in list(d.items()):
    ans += k * v
print(("".join(sorted(ans))))

n = int(eval(input()))
d = {}
for i in range(26):
    c = chr(i + ord("a"))
    d[c] = 10**18
for i in range(n):
    s = str(eval(input()))
    de = {}
    for i in range(26):
        c = chr(i + ord("a"))
        de[c] = 0
    for j in range(len(s)):
        if s[j] not in de:
            de[s[j]] = 1
        else:
            de[s[j]] += 1
    for k, v in list(de.items()):
        d[k] = min(d[k], de[k])
d = sorted(d.items())
# print(d)
ans = ""
for k, v in d:
    ans += k * v
print(ans)

-for k in range(97, 97 + 26): -    d[chr(k)] = 51 +for i in range(26): +    c = chr(i + ord("a")) +    d[c] = 10**18 -    for j in range(97, 97 + 26): -        d[chr(j)] = min(d[chr(j)], s.count(chr(j))) +    de = {} +    for i in range(26): +        c = chr(i + ord("a")) +        de[c] = 0 +    for j in range(len(s)): +        if s[j] not in de: +            de[s[j]] = 1 +        else: +            de[s[j]] += 1 +    for k, v in list(de.items()): +        d[k] = min(d[k], de[k]) +d = sorted(d.items()) +# print(d) -for k, v in list(d.items()): +for k, v in d: -print(("".join(sorted(ans)))) +print(ans)