#!/usr/bin/env python3

n1 = int(input())
l1 = [input().strip() for i in range(n1)]

n2 = int(input())
l2 = [input().strip() for i in range(n2)]

def repr_to_num(ls):
    w = len(ls[0])
    idx = ls[0].index('#')
    n = 1
    for l in ls[1:]:
        n <<= 1
        if idx > 0 and l[idx - 1] == '#':
            n |= 1
            idx = idx - 1
        else:
            idx = idx + 1
    return n

def num_to_repr(n):
    res = [0]
    while n > 1:
        if n % 2 == 0:
            res.append(res[-1] - 1)
        else:
            res.append(res[-1] + 1)
        n //= 2

    shift = min(res)
    res = [i - shift for i in res][::-1]
    w = max(res) + 1

    lines = []
    for pos in res:
        line = '.' * pos + '#' + '.' * (w - pos - 1)
        lines.append(line)

    return lines


a = repr_to_num(l1)
b = repr_to_num(l2)
c = a + b

lines = num_to_repr(c)

print(len(lines))
for line in lines:
    print(line)
