• + 1 comment
    import re
    N=int(input())
    pattern =r'(\#[0-9a-fA-F]{3,6})(;|,|.;)'
    texto=""
    for _ in range (N):
        texto =texto+''.join(input())
    
    matches =re.findall(pattern,texto)
    
    for match in matches:
        print(match[0])