def extract_arguments(fh):
    datasets = []
    while True:
        n = int(fh.readline().strip())
        if n == 0:
            break
        pieces = []
        for _ in range(6 * n):
            pieces.append(fh.readline().strip())
        datasets.append((n, pieces))
    return datasets

# Example usage:
# with open('input.txt', 'r') as fh:
#     datasets = extract_arguments(fh)
#     for n, pieces in datasets:
#         print(n, pieces)