#include <stdio.h>

struct Task {
    int taskID;
    int priority;
};

struct Task heap[1000];
int size = 0;

void swap(struct task *a, struct task task *b) {
    struct task temp = *a;
    *a = *b;
    *b = temp;
}
void inserttask(int id, int p) {
    heap[size].taskID = id ;
    heap[size].priority = p;
    int current = size;
    size++;
    
    while (curren > 0 && heap[(current - 1) / 2].priority) >
heap[current].priority) {
        swap(&heap[current], &heap[current - 1) / 2]);
                      current = (current - 1) / 2;
       }
   }
   
   int main() {
       int n, id, p;
       scanf("%d", %n);
       for (int i = 0; i < n; i++) {
           if (scanf("%d %d", &id, &p) != 2) {
               printf("Invalid input \n");
               while(getchar() != '\n');
               continue;
           }
           insertTask(id, p);
           printf("Task Added; %d\n", id);
       }
       if (size > 0)
           printf("Task with highest priority: %d", heap[0].taskID);
        else
            printf("No valid tasks in the list");
            
        return 0;
   }
           }
       }
   }