def get_input(p, fn=lambda a: a.strip()): with open(p) as f: return [fn(line) for line in f.readlines()] def transpose(grid): return [list(row) for row in list(zip(*grid))]