import sys x = 0 y = 0 xlim = 10000 ylim = 10000 xlast = True ylast = True steps = 0 while steps < 200 and altitude != 0: sys.stdout.flush() sys.stdout.write(str(x) + " " + str(y)) line = sys.stdin.readline() if line == "Invalid Query": if xlast: xlim = x else: ylim = y else: altitude = int(line.strip()) if altitude < 0: if x < xlim - 1: x = x + 1 xlast = True else: y = y + 1 ylast = True else: if altitude > 0: if x > 0: x = x - 1 xlast = True else: y = y - 1 ylast = True else: break