#include <stdio.h>
struct Task {
    int id, priority;
};
struct Task heap[1000];
int size = 0;
void swap(int i, int j) {
    struct Task t = heap[i];
    heap[i] = heap[j];
    heap[j] = t;
}
void insert(int id, int p) {
    int i = size++;
    heap[i].id = id;
    heap[i].priority = p;
    while (i > 0 && heap[(i - 1) / 2].priority > heap[i].priority) {
        swap(i, (i - 1) / 2);
        i = (i - 1) / 2;
    }
}
int main() {
    int n;
     scanf("%d", &n);
     for (int i = 0; i < n; i++) {
         scanf("%d %d", &id, &p);
         if (id < 0 || p < 0) {
             printf("Invalid input\n");
         } else {
             insert(id, p);
             printf("Task Added:%d\n", id);
         }
     }
     if (size > 0)
        printf("Task with Highest Priority:%d\n", heap[0].id);
        return 0;
}