402907: GYM100942 H Messenger

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Messengertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

New technologies appear every day. A famous message delivery service called «LCI» was launched a few years ago. The messenger became popular by its technical error — all communication centers distort messages. A numeric key Xi was assigned to each communication center, and transition of each message inverted its prefix of Xi characters length and the suffix of L - Xi characters, where L is a length of the message. The text becomes unrecognizable, but people like it.

Version 16.0, which fixes the annoying bug, has recently been released. Messages began to reach the destination without changes, but it turned out that «LCI» became as boring as hundreds of other messengers. People lost all their interest and deleted their accounts.

The messenger developers have tried to return the well-loved pecularity, but it turned out that it was impossible to rollback the communication centers to the previous firmware. Now, it is necessary to create an «LCI» Network Emulator, which can calculate the final message by sent message and passed centers keys.

Input

The first line contains the sent message — an L character string (1 ≤ L ≤ 200 000) consisting of lowercase Latin letters, numbers, spaces and punctuation marks. The second line contains the single integer N (1 ≤ N ≤ 200 000) — a number of communication centers passed by the message. The next N lines contain communication center keys, Xi (0 ≤ Xi ≤ L), in accordance with their passing order.

Output

A single line should contain the final message.

ExamplesInput
abcde
5
2
3
5
3
1
Output
baedc

加入题单

算法标签: