import heapq

def main():
    try:
        n = int(input().strip())
        heap = []

        for _ in range(n):
            line = input().strip()
            try:
                taskID, priority = map(int, line.split())
                if taskID < 0 or priority < 0:
                    raise ValueError
                heapq.heappush(heap, (priority, taskID))
                print(f"Task Added: {taskID}")
            except:
                print("Invalid Input")

        if heap:
            # Get task with the highest priority (lowest priority value)
            highest_priority_task = heapq.nsmallest(1, heap)[0]
            print(f"Task with Highest Priority: {highest_priority_task[1]}")

    except:
        print("Invalid Input")

main()