#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
struct Node{
    int data;
    struct Node*next;
};
struct Node*createNode(int data){
    struct Node* newNode=(struct Node*)malloc(sizeof(struct Node));
    newNode->data=data;
    newNode->next=NULL;
    return newNode;
}
void append(struct Node**head,int data){
    struct Node*newNode=createNode(data);
    if(*head==NULL){
        *head=newNode;
        return;
    }
    struct Node*temp=*head;
    while(temp->next !=NULL){
        temp=temp->next;
    }
    temp->next=newNode;
}
int search(struct Node*head,int target){
    struct Node*current=head;
    while(current !=NULL){
        if(current->data==target)
        return 1;
       current=current->next; 
    }
    return 0;
}
int main(){
    int n;
    if(scanf("%d",&n)!=1||n<1||n>1000){
        printf("Invalid input");
        return 0;
    }
    struct Node*head=NULL;
    for(int i=0;i<n;i++){
        char buffer[50];
        if(scanf("%s"))
    }
}