import numpy as np





n = int(eval(input()))

l = [[0] * (ord('z') - ord('a') + 1) for _ in range(n)]

for i in range(n):

    S = eval(input())

    for s in S:

        idx = ord(s) - ord('a')

        l[i][idx] += 1

l = np.array(l)

l = np.rot90(l, -1)

ans = ''

for j in range(len(l)):

    num = min(l[j])

    ans += chr(ord('a') + j) * num

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

l = [eval(input()) for _ in range(n)]

ans = ''

for i in range(ord('a'), ord('z') + 1):

    s = chr(i)

    num = float('inf')

    for j in l:

        num = min(num, j.count(s))

    ans += s * num

print(ans)
import numpy as np

n = int(eval(input()))
l = [[0] * (ord("z") - ord("a") + 1) for _ in range(n)]
for i in range(n):
    S = eval(input())
    for s in S:
        idx = ord(s) - ord("a")
        l[i][idx] += 1
l = np.array(l)
l = np.rot90(l, -1)
ans = ""
for j in range(len(l)):
    num = min(l[j])
    ans += chr(ord("a") + j) * num
print(ans)

n = int(eval(input()))
l = [eval(input()) for _ in range(n)]
ans = ""
for i in range(ord("a"), ord("z") + 1):
    s = chr(i)
    num = float("inf")
    for j in l:
        num = min(num, j.count(s))
    ans += s * num
print(ans)

-import numpy as np - -l = [[0] * (ord("z") - ord("a") + 1) for _ in range(n)] -for i in range(n): -    S = eval(input()) -    for s in S: -        idx = ord(s) - ord("a") -        l[i][idx] += 1 -l = np.array(l) -l = np.rot90(l, -1) +l = [eval(input()) for _ in range(n)] -for j in range(len(l)): -    num = min(l[j]) -    ans += chr(ord("a") + j) * num +for i in range(ord("a"), ord("z") + 1): +    s = chr(i) +    num = float("inf") +    for j in l: +        num = min(num, j.count(s)) +    ans += s * num