• + 0 comments
    import re
    
    n, m = map(int, input().split())
    
    matrix = [input() for _ in range(n)]
    decoded = ''.join(sum(zip(*matrix), ()))
    
    pattern = r'(?<=\w)([^\w]+)(?=\w)'
    print(re.sub(pattern, ' ', decoded))