import sys
sys.stdin = open('input.txt')
T = int(input())
for tc in range(1, T + 1):
    sent = [[] for _ in range(5)]
    for i in range(5):
        sent[i] = list(input())
    res = [len(x) for x in sent]
    result = []
    for _ in range(max(res)):
        for s in sent:
            if not s:
                pass
            else:
                temp = s.pop(0)
                result.append(temp)
    print(f'#{tc}', ''.join(result))

17814e030441f21077ab71cde0e513b0cce167b4
<mask token>

<mask token>
for tc in range(1, T + 1):
    sent = [[] for _ in range(5)]
    for i in range(5):
        sent[i] = list(input())
    res = [len(x) for x in sent]
    result = []
    for _ in range(max(res)):
        for s in sent:
            if not s:
                pass
            else:
                temp = s.pop(0)
                result.append(temp)
    print(f'#{tc}', ''.join(result))

<mask token>
sys.stdin = open('input.txt')
T = int(input())
for tc in range(1, T + 1):
    sent = [[] for _ in range(5)]
    for i in range(5):
        sent[i] = list(input())
    res = [len(x) for x in sent]
    result = []
    for _ in range(max(res)):
        for s in sent:
            if not s:
                pass
            else:
                temp = s.pop(0)
                result.append(temp)
    print(f'#{tc}', ''.join(result))

import sys
sys.stdin = open('input.txt')
T = int(input())
for tc in range(1, T + 1):
    sent = [[] for _ in range(5)]
    for i in range(5):
        sent[i] = list(input())
    res = [len(x) for x in sent]
    result = []
    for _ in range(max(res)):
        for s in sent:
            if not s:
                pass
            else:
                temp = s.pop(0)
                result.append(temp)
    print(f'#{tc}', ''.join(result))
