#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

struct node{
    int data;
    struct node* prev;
    struct node* next;
    
};
struct node* createnode(int data){
    struct node* newnode=(struct node*)malloc(sizeof(struct node));
    newnode->=data;
    newnode->prev=NULL;
    newnode->next=NULL;
    return newnode;
}
void append(struct node** head,int data){
    struct node* newnode=creatrnode(data);
    if(*head==NULL){
        *head=newnode;
        return;
    }
    struct node* temp=*head;
    while(temp->next !=NULL){
        temp=temp->next;
    }
    temp->next=newnode;
    newnode->prev=temp;
}
void sortlist(struct node* head){
    struct node* i;
    struct node* j;
    int temp;
    for(i=head;i!=NULL;i=i->next){
        for(j=next;j!=NULL;j=j->next){
        if(i->data>j->data){
            temp=i->data;
            i->data=j->data;
            j->data=temp;
            
        }
    }
    }
}
void sortlist(struct node* head){
    struct node* temp=head;
    while(temp !=NULL){
        printf("%d",temp->data);
        temp=temp->next;
    }
    
    print("\n");
    
}
int main(){
    int n;
    if(scanf("%d",&n)!=1||n<1||n>1000){
        printf("Invalid input\n");
        return 0;
    }
    struct node* head=NULL;
    for(int i=0;i<n;i++){
        char buffer[50];
        if(scanf("%s",buffer)!=1){
            printf("Invalid input\n");
            return 0;
        }
        for()
    }
}