import sys init = [0, 0] for line in sys.stdin: a = line.split(";") for index in range(0, len(a)): site = a[index] # print(site) if len(site) == 0: continue if len(site) > 3: continue if site[0] not in ["A", "D", "W", "S"]: ...