#include <stdio.h>
#include <stdlib.h>
#include<string.h>
typedef struct node{
    char data[100];
    struct node*next;
}Node;
struct node*createnode(char value[]){
    struct node*newnode=(struct node*)malloc(sizeof(struct node));
    strcpy(newnode->data,value);
    newnode->next=NULL;
    return newnode;
}
void InsertAtEnd(struct node**head,struct node**tail,char value[]){
	struct node*newnode=createnode(value);
	if(*head==NULL){
	    *head=newnode;
	    *tail=newnode;
	}
	else{
	    (*tail)->next=newnode;
	    *tail=newnode;
	}
}   
void printlist(struct node*head){
    struct node*temp=head;
    while(temp!=NULL){
        printf("%s->",temp->data);
        temp=temp->next;
    }
    printf("NULL\n");
}
int main(){
    int n,i;
    scanf("%d",&n);
    struct node*head=NULL;
    struct node*tail=NULL;
    for(i=0;i<n;i++){
        char data[100];
        scanf("%s",data);
    }
    for(i=0;data[i]!=NULL;i++){
        if(!isalpha(data[i])){
            printf("Invalid input\n");
            return 0;
        }
    }
    insertAtend(&head,&tail,data); 

    printlist(head);

    return 0;
}