#P4807. Pasha and String

Pasha and String

Pasha and String

题面翻译

给定一个字符串s,对其进行m次操作,第i次操作给一个数字aia_i,表示将字符串s的第x个位置到第len-x+1这段字翻转,求m次操作后的结果。

题目描述

Pasha got a very beautiful string s s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to s |s| from left to right, where s |s| is the length of the given string.

Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m m days performing the following transformations on his string — each day he chose integer ai a_{i} and reversed a piece of string (a segment) from position ai a_{i} to position sai+1 |s|-a_{i}+1 . It is guaranteed that 2ai<=s 2·a_{i}<=|s| .

You face the following task: determine what Pasha's string will look like after m m days.

输入格式

The first line of the input contains Pasha's string s s of length from 2 2 to 2105 2·10^{5} characters, consisting of lowercase Latin letters.

The second line contains a single integer m m ( 1<=m<=105 1<=m<=10^{5} ) — the number of days when Pasha changed his string.

The third line contains m m space-separated elements ai a_{i} ( 1<=ai 1<=a_{i} ; 2ai<=s 2·a_{i}<=|s| ) — the position from which Pasha started transforming the string on the i i -th day.

输出格式

In the first line of the output print what Pasha's string s s will look like after m m days.

样例 #1

样例输入 #1

abcdef
1
2

样例输出 #1

aedcbf

样例 #2

样例输入 #2

vwxyz
2
2 2

样例输出 #2

vwxyz

样例 #3

样例输入 #3

abcdef
3
1 2 3

样例输出 #3

fbdcea