Shuffling
The deck shuffling process is carried out as follows: The deck is divided into several segments using partitions, which are identified by the number of the card that follows each partition (cards are numbered starting from one). The resulting blocks of cards are then rearranged in reverse order, while keeping the order of cards within each block unchanged.
Given the values of the cards and the specified partition numbers, your task is to determine the order of the cards after one such shuffle.
Input
The input consists of two lines. The first line lists the card values in order, separated by spaces. Each card value is guaranteed to have an absolute value of no more than 10^12, and there are no more than 10^6 cards. The second line provides the partition numbers in ascending order, separated by spaces. Partitions can only be placed between cards, and there can be no more than one partition in any gap between cards.
Output
The output should be a single line containing the sequence of card values after the shuffle.