a = int(eval(input()))

ar = []

for i in range(a):

    l = eval(input())

    ar.append(l)

br = set(list(ar[0]))

dr = []

for r in br:

    cr =[]

    count = 0

    for rr in ar:

        if rr.count(r) > 0:

            cr.append(rr.count(r))

            count += 1

        if count == a:

            for i in range(min(cr)):

                dr.append(r)

print(("".join(sorted(dr))))

                
a = int(eval(input()))

ar = []

l = 51

t = ''

for i in range(a):

    j = eval(input())

    ar.append(j)

    if len(j) < l:

        l = len(j)

        t = j

T = list(t)

br = []

for r in set(T):

    count = 0

    cr = []

    for l in ar:

        if r not in l:

            break

        else:

            cr.append(l.count(r))

            count += 1

    if count == len(ar):

        for i in range(min(cr)):

            br.append(r)

br.sort()

print(("".join(br)))
a = int(eval(input()))
ar = []
for i in range(a):
    l = eval(input())
    ar.append(l)
br = set(list(ar[0]))
dr = []
for r in br:
    cr = []
    count = 0
    for rr in ar:
        if rr.count(r) > 0:
            cr.append(rr.count(r))
            count += 1
        if count == a:
            for i in range(min(cr)):
                dr.append(r)
print(("".join(sorted(dr))))

a = int(eval(input()))
ar = []
l = 51
t = ""
for i in range(a):
    j = eval(input())
    ar.append(j)
    if len(j) < l:
        l = len(j)
        t = j
T = list(t)
br = []
for r in set(T):
    count = 0
    cr = []
    for l in ar:
        if r not in l:
            break
        else:
            cr.append(l.count(r))
            count += 1
    if count == len(ar):
        for i in range(min(cr)):
            br.append(r)
br.sort()
print(("".join(br)))

+l = 51 +t = "" -    l = eval(input()) -    ar.append(l) -br = set(list(ar[0])) -dr = [] -for r in br: +    j = eval(input()) +    ar.append(j) +    if len(j) < l: +        l = len(j) +        t = j +T = list(t) +br = [] +for r in set(T): +    count = 0 -    count = 0 -    for rr in ar: -        if rr.count(r) > 0: -            cr.append(rr.count(r)) +    for l in ar: +        if r not in l: +            break +        else: +            cr.append(l.count(r)) -        if count == a: -            for i in range(min(cr)): -                dr.append(r) -print(("".join(sorted(dr)))) +    if count == len(ar): +        for i in range(min(cr)): +            br.append(r) +br.sort() +print(("".join(br)))