import re
N = int(input())
if N > 0 and N < 50:
    for _ in range(N):
        css = input()
        col_codes = re.findall(r".(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3})",css) #return a list with all the matches in the css code
        if col_codes:
            print(*col_codes,sep="\n")
01071df38bb4ee55ee2b478bedd176e188b8d645
<mask token>

<mask token>
if N > 0 and N < 50:
    for _ in range(N):
        css = input()
        col_codes = re.findall('.(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3})', css)
        if col_codes:
            print(*col_codes, sep='\n')

<mask token>
N = int(input())
if N > 0 and N < 50:
    for _ in range(N):
        css = input()
        col_codes = re.findall('.(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3})', css)
        if col_codes:
            print(*col_codes, sep='\n')

import re
N = int(input())
if N > 0 and N < 50:
    for _ in range(N):
        css = input()
        col_codes = re.findall('.(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3})', css)
        if col_codes:
            print(*col_codes, sep='\n')

import re
N = int(input())
if N > 0 and N < 50:
    for _ in range(N):
        css = input()
        col_codes = re.findall(r".(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3})",css) #return a list with all the matches in the css code
        if col_codes:
            print(*col_codes,sep="\n")