1872. Encrypted

单点时限: 2.0 sec

内存限制: 256 MB

You and your friends have decided to create your own encryption scheme (bad idea). An encrypted message consists of 3 parts:

1) A character string pool

2) A interger array data

3) A interger array keys

To decrypt character i of the message, first find the smallest positive integer k such that (data[i] * k) % key[i] = 1

Above % denotes the modulus operator. Character i of the message will be character j in pool, where j is given by j = k % (length of pool)

输入格式

There are many tests.In each test there are four lines,the first line is the pool,the length len(1<=len<=100000),the second line is a interger n(1<=n<=100000),then the third line there are n interger in array data.The forth line also n interger in array key.

输出格式

Output the decrypted string. Constraints will ensure that the ith element of data is relatively prime to the ith element of keys. In other words, the largest positive integer that divides data[i] and keys[i] will be 1, for all i.

样例

Input
ABCDEFGHIJKLMNOPQRSTUVWXYZ
15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
17 17 17 17 17 17 17 17 17 17 17 17 17 17 17
AEIOUAEIOUaeiouaeiou
15
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5
2 3 4 5 6 7 8 9 10 11 13 15 16 17 18
Output
BJGNHDFPCMOKELI
EIOUAEIOUaEOeoe

1 人解决,16 人已尝试。

1 份提交通过,共有 59 份提交。

9.9 EMB 奖励。

创建: 16 年,1 月前.

修改: 6 年,8 月前.

最后提交: 3 年,5 月前.

来源: N/A

题目标签