//For HackerRank and HackerEarth platform below implementation is preferred: while True: try : line = input() ... except EOFError: break;