This page is still under construction.

Parts of this page are still being built. What you see may change.

Perfect Shuffle

Time limit1sMemory limit128 MB

Summary
Interleave the top and bottom halves of a card list to perform one perfect shuffle for each test case.
Level

Easy2 of 10

Topics
Simulation, Array
Solved
No attempts yet

Problem

A perfect shuffle splits a deck exactly in half and then lays the cards down alternately from the two halves, starting with the top half.

Given a deck of cards, perform one perfect shuffle. If the number of cards is odd, the top half gets one more card than the bottom half.

Input

The input holds several test cases. Each test case begins with a line containing one integer nn, the number of cards (1≤n≤10001 \le n \le 1000). Each of the next nn lines holds the name of a card, listed from the top of the deck down. A name is 1 to 80 characters long and contains only capital letters and dashes. Within one test case all card names are different. The input ends with a line containing a single 0.

Output

For each test case, print nn lines holding the deck after one perfect shuffle. Print no extra spaces, and print no blank line between test cases.

Examples1

  1. Example 1

    Input
    4
    ACE
    KING
    QUEEN
    JACK
    5
    SKIP
    DRAW-TWO
    REVERSE
    WILD
    WILD-DRAW-FOUR
    0
    
    Expected output
    ACE
    QUEEN
    KING
    JACK
    SKIP
    WILD
    DRAW-TWO
    WILD-DRAW-FOUR
    REVERSE