#include <stdio.h>
#include <stdlib.h>

#define MAX 1000

typedef struct {
    int taskID;
    int priority;
} Task;

Task heap[MAX];
int size = 0;

void swap(Task* a, Task* b) {
    Task temp = *a;
    *a = *b;
    *b = temp;
}

void heapifyUp(int index) {
    while (index > 0) {
        int parent = (index - 1) / 2;
        if (heap[parent].priority > heap[index].priority) {
            swap(&heap[parent], &heap[index]);
            index = parent;
        } else {
            break;
        }
    }
}

void insert(int taskID, int priority) {
    if (size >= MAX) {
        printf("Heap is full. Cannot insert more tasks.\n");
        return;
    }
    heap[size].taskID = taskID;
    heap[size].priority = priority;
    heapifyUp(size);
    size++;
}

int main() {
    int n;
    if (scanf("%d", &n) != 1 || n < 1 || n > MAX) {
        printf("Invalid Input\n");
        return 0;
    }

    for (int i = 0; i < n; i++) {
        int taskID, priority;
        if (scanf("%d %d", &taskID, &priority) == 2) {
            if (taskID < 0 || priority < 0) {
                printf("Invalid Input\n");
                // Consume the rest of the line to clear invalid input
                int c;
                while ((c = getchar()) != '\n' && c != EOF);
            } else {
                insert(taskID, priority);
                printf("Task Added: %d\n", taskID);
            }
        } else {
            // Consume the rest of the line to clear invalid input
            int c;
            while ((c = getchar()) != '\n' && c != EOF);
            printf("Invalid Input\n");
            i--; // Decrement i to retry the current iteration
        }
    }

    if (size > 0) {
        printf("Task with Highest Priority: %d\n", heap[0].taskID);
    }

    return 0;
}
```