#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN 256

// Node in circular linked list
typedef struct Node {
    char *msg;
    struct Node *next;
} Node;

// Create a new node
Node* newNode(const char *s) {
    Node* nd = (Node*)malloc(sizeof(Node));
    if (!nd) {
        perror("malloc");
        exit(EXIT_FAILURE);
    }
    nd->msg = strdup(s);  // allocate and copy string
    if (!nd->msg) {
        perror("strdup");
        exit(EXIT_FAILURE);
    }
    nd->next = NULL;
    return nd;
}

// Free the whole circular list
void freeList(Node *head) {
    if (!head) return;
    Node *cur = head->next;
    while (cur != head) {
        Node *next = cur->next;
        free(cur->msg);
        free(cur);
        cur = next;
    }
    free(head->msg);
    free(head);
}

// Print the circular list once, starting from head
void printList(Node *head) {
    if (!head) return;
    Node *cur = head;
    do {
        printf("%s", cur->msg);
        cur = cur->next;
        if (cur != head) printf(" ");
    } while (cur != head);
    printf("\n");
}

int main(void) {
    int n;
    if (scanf("%d", &n) != 1) {
        printf("Invalid input\n");
        return 0;
    }
    // consume newline
    getchar();
    
    // Read n message strings
    char buffer[MAX_LEN];
    // We read the entire line, then split
    if (!fgets(buffer, MAX_LEN, stdin)) {
        printf("Invalid input\n");
        return 0;
    }
    // remove trailing newline
    buffer[strcspn(buffer, "\n")] = '\0';
    
    // Tokenize
    char *tokens[100];
    int count = 0;
    char *p = strtok(buffer, " \t");
    while (p != NULL && count < 100) {
        tokens[count++] = p;
        p = strtok(NULL, " \t");
    }
    
    if (count != n) {
        printf("Invalid input\n");
        return 0;
    }
    
    // Read the new message (to insert in middle)
    char newmsg[MAX_LEN];
    if (!fgets(newmsg, MAX_LEN, stdin)) {
        printf("Invalid input\n");
        return 0;
    }
    // Remove newline
    newmsg[strcspn(newmsg, "\n")] = '\0';
    
    // Build circular linked list with initial messages
    Node *head = NULL;
    Node *tail = NULL;
    for (int i = 0; i < n; i++) {
        Node *nd = newNode(tokens[i]);
        if (!head) {
            head = nd;
            tail = nd;
            nd->next = head;  // circular
        } else {
            tail->next = nd;
            tail = nd;
            tail->next = head;
        }
    }
    
    // Insert the new message in the middle
    // Define middle position: after floor(n/2) nodes
    int mid_pos = n / 2;  // e.g. if n=4, mid_pos=2, insert after 2 nodes
    
    Node *cur = head;
    for (int i = 1; i < mid_pos; i++) {
        cur = cur->next;
    }
    // cur now at the node after which we insert
    Node *nd_new = newNode(newmsg);
    nd_new->next = cur->next;
    cur->next = nd_new;
    // If inserting after tail, update tail
    if (cur == tail) {
        tail = nd_new;
    }
    // Maintain circularity: tail->next should still be head
    tail->next = head;
    
    // Print result
    printList(head);
    
    // Clean up
    freeList(head);
    return 0;
}