#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct Node {
    char task[101];
    struct Node* next;
} Node;

int containsDigit(char* str) {
    for (int i = 0; str[i]; i++) {
        if (isdigit(str[i])) return 1;
    }
    return 0;
}

int main() {
    int n;
    if (scanf("%d", &n) != 1 || n < 0 || n > 1000) {
        printf("Invalid input\n");
        return 0;
    }

    Node *head = NULL, *tail = NULL;

    // Read existing tasks
    for (int i = 0; i < n; i++) {
        char task[101];
        if (scanf("%s", task) != 1) {
            printf("Invalid input\n");
            return 0;
        }

        Node* newNode = (Node*)malloc(sizeof(Node));
        strcpy(newNode->task, task);
        newNode->