#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.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=data;
  - newNode->prev = NULL;
    newNode->next = NULL;
    return newNode;
}

void append(struct Node** head, int data){
    struct Node* newNode = createNode(data);
    if(*head == NULL){
        *head = newNode;
        return;
    }

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;
    newNode->prev = temp;
}
void sortList(struct Node*head){
    struct Node*i;
    struct Node*j;
    int temp;
    for(i=head;i!=NULL;i>next){
        for(j=i>next;j!=NULL;j=j>next){
           if(i>data>j>data){
               temp=i>data;
               i>data=j>data;
               j>data=temp;
           }
        }
    }
}
void printList(struct Node* head){
    struct Node* temp = head;
    while(temp != NULL){
        printf("%d", temp->data);
        temp = temp->next;
    }
    printf("\n");
}
int main(){
    int n, pos;
    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(int k=0;k<strlen(buffer):k++){
            if(!isdigit(buffer)[k] && !(k==0 && buffer[k]=='')){
                printf("Invalid input\n");
                return 0;
            }
            
            }
        }