#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
typedef task {
    int id;
    int priority;
};

void swap(struct Task *a,struct Task *b){
    struct Task temp = *a;
    *a = *b;
    *b = temp;
}void heapify(struct Task heap[],int n,int i){
    int smallest=i;
    int left=2*i+1;
    int right=2*i+2;
    if(left<n && heap[left].priority<heap[smallest].priority)
    smallest=left;
    if(right<n && heap[right].priority<heap[smallest].priority)
    smallest=right;
    if(smallest!=i){
        swap(&heap[i],&heap[smallest]);
        heapify(heap,n,smallest);
    }
}

int main(){
    int n;
   if(scanf("%d",&n)!=1||n<=0){
        printf("Invalid Input\n");
        return 0;
   }struct Task heap[1000];
   int size=0;
 
    for(int i=0;i<n;i++){
        int id,priority;
        if(scanf("%d%d",&id,&priority)!=2){
             printf("Invalid Input\n");
             while(getchar()!='\n');
              continue;
        }
        heap[size].id=id;
        heap[size].priority=priority;
        size++;
        for(int j=size/2-1;j>=0;j--)
        heapfy(heap,size,j);
        printf("Task added:%d\n",id);
    }
    if(size>0){
        printf("Task with highest priority:%d\n",heap[0].id);
        return 0;
    }