Faro Shuffle
At the Blackjack table, you notice some dealers doing the faro shuffle. The faro shuffle is a method for shuffling a deck of cards, in which the deck is split into packets of equal size, and the packets are perfectly interweaved with each other. When the shuffle is performed, the original card at the top of the deck stays at the top of the deck.
For example, to shuffle the deck 12345678
, it would be split into packets,
1234
and 5678
, and then interweaved in the following way:
1 2 3 4
5 6 7 8
Result:
15263748
You think this could be a nice way to hide a secret message. You could write a character on each card, and then after a certain amount of faro shuffles, your secret message would appear.
Given a deck of cards and the amount of shuffles needed to reveal the answer, what is the final ordering of the cards?
Input
The first line consists of an integer
, the number of times the shuffle should be done.
The next line consists of a word of length
consisting of uppercase characters, lowercase characters, numbers, and special characters
_
, and -
. This string represents the order of the cards in the deck, with the first character being the first card, the second character being the second, and so forth.
It is guaranteed that the number of cards in the deck is even.
Output
Print the result of the deck after all the shuffles have been completed.
Example
Input
2
AADIEDLE
Output
ADELAIDE
The faro shuffle is performed times. Below is a visualization of what happens at each shuffle.
Shuffle :
Split:
AADI EDLE
Shuffle:
A A D I
E D L E
Result:
AEADDLIE
Shuffle :
Split:
AEAD DLIE
Shuffle:
A E A D
D L I E
Result:
ADELAIDE
Comments