• + 0 comments

    import re

    n, m = input().strip().split()

    tt = []

    ss = []

    for _ in range(int(n)):

    itm = input()
    
    tt.append(itm)
    

    res = "".join(tt)

    for nm in range(int(m)):

    for th in range(nm, len(res), int(m)):
    
        ss.append(res[th])
    

    fin = re.sub(r"[!,@,#,$,%,&]+(?=([A-z0-9]))", " ", "".join(ss)) print(fin)