Email from the Professor

No attempts yetTime limit1sMemory limit128 MB

Problem

Being a judge for a programming contest can be stressful. Judges must prepare challenging, interesting problems and, above all, keep them secret until contest day. Judges often use email to discuss problems, but email is not a safe channel for confidential material: a message can be sent to the wrong recipient by mistake — a student, or worse, a contestant.

To address this, one of the judges, Prof. Nash V. Ruhdney, proposed a way to exchange messages confidentially. Given a message of length nn, write it into a rectangle of width kk, filling row by row (left to right, top to bottom), and then read it column by column in a chosen order. That column order is the encryption key.

For example:

Message     : I am Prof. Nash V. Ruhdney
Key         : 3 7 4 1 2 6 5
Grid        : I   a m   P r
              o f .   N a s
              h   V .   R u
              h d n e y * *      ('*' is a blank padding cell, not part of the message)
Cipher text : m .e N yIohha.VnrsuPaR f d

The key is a permutation of 11 to kk. The jj-th value of the key is the rank of column jj; columns are read in increasing order of their rank. In the example the ranks are 3 7 4 1 2 6 5, so column 44 (rank 11) is read first, then column 55 (rank 22), then column 11 (rank 33), and so on. Padding cells that lie past the end of the message are skipped.

The professor emails the cipher text while sending the key through another channel, such as a phone call or SMS, to reduce the risk of a leaked email.

Naturally the professor will not encrypt messages by hand. Write a program that performs the encryption for him.

Input

The input contains several test cases. Each test case is given as follows:

  • The first line is a message of length nn (1n10001 \le n \le 1000) made of ASCII characters; it may contain spaces. The whole line is the message, so leading and trailing spaces are part of it.
  • The second line contains the rectangle width kk (1k10001 \le k \le 1000), followed by kk integers separated by single spaces. These kk integers form a permutation of 11 to kk and are the encryption key.

The input ends at end of file.

Output

For each message, print its cipher text on its own line.