#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node*next;
};
int main(){
    int n,val;
    scanf("%d",&n);
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    struct Node *head=NULL,*tail=NULL,*node;
    for(int i=0;i<n;i++){
        if(scanf("%d,&val)!= || val<-1000 || val > 1000){
            printf("Invalid input");
            return 0;
        }
        node=malloc(sizeof(struct Node));
        node->data = val;
        node->next=NULL;
        if(!head)head=node;
        else tail->next=node;
        tail=node;
    }
    for(node=head;node;node=node->next)
       printf("%d ",node->data);
    return 0;
}
       

    
        }
    }