n = int(eval(input()))

G = []

for _ in range(n):

    S = list(input().strip())

    C = {}

    for i in range(len(S)):

        x = S[i]

        if x not in C:

            C[x] = 0

        C[x] += 1

    G.append(C)

A = {}

for i in range(97,123):

    flag = 0

    cmin = 50

    for C in G:

        if chr(i) not in C:

            flag = 1

            break

        cmin = min(cmin,C[chr(i)])

    if flag==0:

        A[chr(i)] = cmin

A = sorted(list(A.items()),key=lambda x:x[0])

x = ""

for y in A:

    a,k = y[0],y[1]

    x += a*k

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

S = [input().strip() for _ in range(n)]

C = {chr(i):0 for i in range(97,123)}

for i in range(len(S[0])):

    C[S[0][i]] += 1

for j in range(1,n):

    C1 = {chr(i):0 for i in range(97,123)}

    for i in range(len(S[j])):

        C1[S[j][i]] += 1

    for i in range(97,123):

        C[chr(i)] = min(C[chr(i)],C1[chr(i)])

        

A = []

for i in range(97,123):

    A.append(chr(i)*C[chr(i)])

print(("".join(sorted(A))))
n = int(eval(input()))
G = []
for _ in range(n):
    S = list(input().strip())
    C = {}
    for i in range(len(S)):
        x = S[i]
        if x not in C:
            C[x] = 0
        C[x] += 1
    G.append(C)
A = {}
for i in range(97, 123):
    flag = 0
    cmin = 50
    for C in G:
        if chr(i) not in C:
            flag = 1
            break
        cmin = min(cmin, C[chr(i)])
    if flag == 0:
        A[chr(i)] = cmin
A = sorted(list(A.items()), key=lambda x: x[0])
x = ""
for y in A:
    a, k = y[0], y[1]
    x += a * k
print(x)

n = int(eval(input()))
S = [input().strip() for _ in range(n)]
C = {chr(i): 0 for i in range(97, 123)}
for i in range(len(S[0])):
    C[S[0][i]] += 1
for j in range(1, n):
    C1 = {chr(i): 0 for i in range(97, 123)}
    for i in range(len(S[j])):
        C1[S[j][i]] += 1
    for i in range(97, 123):
        C[chr(i)] = min(C[chr(i)], C1[chr(i)])
A = []
for i in range(97, 123):
    A.append(chr(i) * C[chr(i)])
print(("".join(sorted(A))))

-G = [] -for _ in range(n): -    S = list(input().strip()) -    C = {} -    for i in range(len(S)): -        x = S[i] -        if x not in C: -            C[x] = 0 -        C[x] += 1 -    G.append(C) -A = {} +S = [input().strip() for _ in range(n)] +C = {chr(i): 0 for i in range(97, 123)} +for i in range(len(S[0])): +    C[S[0][i]] += 1 +for j in range(1, n): +    C1 = {chr(i): 0 for i in range(97, 123)} +    for i in range(len(S[j])): +        C1[S[j][i]] += 1 +    for i in range(97, 123): +        C[chr(i)] = min(C[chr(i)], C1[chr(i)]) +A = [] -    flag = 0 -    cmin = 50 -    for C in G: -        if chr(i) not in C: -            flag = 1 -            break -        cmin = min(cmin, C[chr(i)]) -    if flag == 0: -        A[chr(i)] = cmin -A = sorted(list(A.items()), key=lambda x: x[0]) -x = "" -for y in A: -    a, k = y[0], y[1] -    x += a * k -print(x) +    A.append(chr(i) * C[chr(i)]) +print(("".join(sorted(A))))