Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |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 days performing the following transformations on his string — each day he chose integer a_{i} and reversed a piece of string (a segment) from position a_{i} to position |s| - a_{i} + 1. It is guaranteed that 2·a_{i} ≤ |s|.

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


-----Input-----

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

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

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


-----Output-----

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


-----Examples-----
Input
abcdef
1
2

Output
aedcbf

Input
vwxyz
2
2 2

Output
vwxyz

Input
abcdef
3
1 2 3

Output
fbdcea

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

String algorithms

Mathematics

Constructive algorithms


Solutions:
def __starting_point():
	s = list(input())
	input()
	data = sorted(map(lambda x: int(x) - 1, input().split()))
	data.append(len(s) // 2)
	tr = True
	for i in range(len(data) - 1):
		if tr:
			for j in range(data[i], data[i + 1]):
				(s[j], s[-j - 1]) = (s[-j - 1], s[j])
		tr = not tr
	print(''.join(s))
__starting_point()


I = input
s = list(I())
S = len(s)
n = int(I())
t = 0
(*l,) = sorted(map(int, I().split()))
for i in range(S // 2):
	while t < n and l[t] <= i + 1:
		t += 1
	if t % 2:
		(s[i], s[S - i - 1]) = (s[S - i - 1], s[i])
print(''.join(s))


def main():
	S = list(input())
	n = int(input())
	M = sorted(map(int, input().split()))
	R = [0] * len(S)
	for m in M:
		R[m - 1] += 1
	for i in range(len(S) // 2):
		if R[i] % 2 == 1:
			(S[i], S[len(S) - i - 1]) = (S[len(S) - i - 1], S[i])
		R[(i + 1) % len(S)] += R[i]
	print(''.join(S))
main()


s = list(input())
m = int(input())
n = len(s)
l = [0] * n
a = list(map(int, input().split()))
a.sort()
x = 0
j = 0
i = 0
while i < n and j < m:
	if i == a[j] - 1:
		if x == 0:
			l[i] = 1
			x = 1
		else:
			l[i] = 0
			x = 0
		j += 1
	else:
		if x == 1:
			l[i] = 1
		i += 1
if x == 1:
	k = i + 1
	while k <= (n - i - 1) // 2:
		l[k] = 1
		k += 1
for i in range(n):
	if l[i] == 1:
		(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
print(''.join(s))


s = [i for i in input()]
m = int(input())
n = len(s)
arr = list(map(int, input().split()))
dp = [0] * n
for i in arr:
	dp[i - 1] += 1
	dp[n - i] += 1
for i in range(1, n):
	dp[i] += dp[i - 1]
for i in range((n + 1) // 2):
	if dp[i] & 1 == 1:
		(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
print(''.join(s))


import sys

def write_buffer(i0, a, l, r, buff, st, n):
	k = a - i0
	for j in range(k):
		buff[i0 + j] = st[l + j] if l <= r else st[l - j]
		buff[n + 1 - i0 - j] = st[r - j] if l <= r else st[r + j]
	return (l + k, r - k) if l <= r else (l - k, r + k)

def solve(st, n, xs):
	st = [''] + st + ['']
	(l, r) = (0, n + 1)
	buff = [None] * (n + 2)
	i0 = 0
	xs.sort()
	xs.append((0 + n + 3) // 2)
	for a in xs:
		(l, r) = write_buffer(i0, a, l, r, buff, st, n)
		i0 = a
		(l, r) = (r, l)
	return ''.join(buff)

def main():
	st = [ch for ch in sys.stdin.readline().strip()]
	m = int(sys.stdin.readline().strip())
	xs = list(map(int, sys.stdin.readline().strip().split()))
	res = solve(st, len(st), xs)
	print(res)
main()


(*s,) = input()
input()
(l, cur) = (len(s), 0)
mid = l // 2
c = [0] * (mid + 1)
a = [int(i) - 1 for i in input().split()]
for i in a:
	c[i] += 1
for i in range(mid):
	cur += c[i]
	if cur % 2:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


from collections import Counter

def main():
	string = input()
	n = len(string)
	input()
	switches = [int(c) for c in input().split()]
	switches = sorted((k for (k, v) in Counter(switches).items() if v % 2 != 0))
	acc = [0]
	i = 0
	for sw in sorted(switches):
		for j in range(i, sw - 1):
			acc.append(acc[-1])
			i += 1
		acc.append(acc[-1] + 1)
		i += 1
	for j in range(i, n // 2 + 1):
		acc.append(acc[-1])
	ans = [''] * n
	for (i, c) in enumerate(string):
		if 2 * i < n and acc[i + 1] % 2 == 0 or (2 * i >= n and acc[n - i] % 2 == 0):
			ans[i] = c
		else:
			ans[n - i - 1] = c
	print(''.join(ans))
main()


s = list(input())
m = int(input())
A = [int(a) for a in input().split()]
n = len(s)
C = [0] * n
for i in range(m):
	C[A[i] - 1] += 1
pr = [0] * n
pr[0] = C[0]
for i in range(1, n):
	pr[i] = pr[i - 1] + C[i]
ans = ['.'] * n
for i in range((n + 1) // 2):
	if pr[i] % 2 == 0:
		ans[i] = s[i]
		ans[n - i - 1] = s[n - i - 1]
	else:
		ans[i] = s[n - i - 1]
		ans[n - i - 1] = s[i]
print(''.join(ans))


s = input()
m = int(input())
n = len(s)
lis = sorted(map(int, input().split()))
has = [0] * (n + 3)
for i in range(m):
	a = lis[i]
	has[a - 1] += 1
for i in range(1, n + 2):
	has[i] += has[i - 1]
pre = ''
pos = ''
for i in range(n // 2):
	if has[i] % 2 == 0:
		pre += s[i]
		pos += s[n - i - 1]
	else:
		pre += s[n - i - 1]
		pos += s[i]
if n % 2:
	print(pre + s[n // 2] + pos[::-1])
else:
	print(pre + pos[::-1])


import sys
import math
s = list(input())
l = len(s)
m = int(input())
ai = list(map(int, input().split()))
k = [0] * int(l / 2)
for i in ai:
	k[i - 1] += 1
v = 0
for i in range(int(l / 2)):
	z = (k[i] + v) % 2
	if z != 0:
		(s[i], s[l - i - 1]) = (s[l - i - 1], s[i])
	v = z
print(''.join(s))


import math
import sys
import collections

def In():
	return map(int, sys.stdin.readline().split())
input = sys.stdin.readline

def beaustr():
	s = input().rstrip()
	days = int(input())
	his = set()
	for i in input().split():
		i = int(i)
		if i in his:
			his.discard(i)
		else:
			his.add(i)
	ans = [0] * (len(s) // 2 + 2)
	n = len(s)
	for i in his:
		ans[i - 1] += 1
	res = [i for i in s]
	tolsum = 0
	for i in range((n + 1) // 2):
		tolsum += ans[i]
		tolsum %= 2
		if tolsum:
			(res[i], res[n - i - 1]) = (res[n - i - 1], res[i])
	print(*res, sep='')
beaustr()


def main():
	l = list(input())
	input()
	le = len(l)
	ll = sorted(map(int, input().split()))
	ll.append(le // 2 + 1)
	le -= 1
	for (a, b) in zip(ll[::2], ll[1::2]):
		for i in range(a - 1, b - 1):
			(l[i], l[le - i]) = (l[le - i], l[i])
	print(''.join(l))
main()


s = list(input())
m = int(input())
a = [int(x) for x in input().split()]
n = len(s) // 2
sums = [0] * (n + 1)
for i in a:
	sums[i - 1] += 1
for i in range(1, len(sums)):
	sums[i] += sums[i - 1]
for i in range(n):
	if sums[i] % 2 != 0:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


import sys
s = list(input().strip())
t = int(input())
v = [0] * len(s)
line = list(map(int, input().split()))
for x in line:
	v[x - 1] = 1 - v[x - 1]
k = len(s)
acc = 0
for i in range(k // 2):
	acc += v[i]
	if acc & 1 > 0:
		(s[i], s[k - i - 1]) = (s[k - i - 1], s[i])
print(''.join(s))


a = list(input())
n = int(input())
t = [int(i) for i in input().split()]
t = sorted(t)
s = len(a)
k = 0
for i in range(s // 2):
	while k < n and t[k] - 1 <= i:
		k += 1
	if k % 2 == 1:
		(a[i], a[s - i - 1]) = (a[s - i - 1], a[i])
print(''.join(a))


s = input()
p = len(s)
m = int(input())
a = list(map(int, input().split()))
r = [0] * ((p + 1) // 2)
z = [s[x] for x in range(p)]
for i in range(m):
	r[a[i] - 1] += 1
if p % 2 != 0:
	e = p // 2 + 1
else:
	e = p // 2
sm = 0
for i in range(e):
	sm += r[i]
	if sm % 2 != 0:
		(z[p - 1 - i], z[i]) = (z[i], z[p - 1 - i])
print(''.join(z))


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from collections import defaultdict
from sys import stdin
(s, n, a, mem) = (input(), int(input()), arr_inp(), defaultdict(int))
(ans, c, l) = (list(s), 0, len(s))
for k in a:
	mem[k] += 1
for i in range(l // 2):
	c += mem[i + 1]
	if c & 1:
		(ans[i], ans[l - i - 1]) = (ans[l - i - 1], ans[i])
print(''.join(ans))


class CodeforcesTask525BSolution:

	def __init__(self):
		self.result = ''
		self.string = ''
		self.m = 0
		self.a = []

	def read_input(self):
		self.string = input()
		self.m = int(input())
		self.a = [int(x) for x in input().split(' ')]

	def process_task(self):
		ns = list(self.string)
		n = len(ns)
		reve = [False] * (n // 2 + n % 2)
		for m in range(self.m):
			reve[self.a[m] - 1] = not reve[self.a[m] - 1]
		to_reve = [False] * (n // 2 + n % 2)
		doing = False
		for x in range(n // 2 + n % 2):
			if doing:
				if not reve[x]:
					to_reve[x] = True
				else:
					doing = False
			elif reve[x]:
				doing = True
				to_reve[x] = True
		for x in range(n // 2 + n % 2):
			if to_reve[x]:
				(ns[x], ns[n - x - 1]) = (ns[n - x - 1], ns[x])
		self.result = ''.join(ns)

	def get_result(self):
		return self.result
Solution = CodeforcesTask525BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import *
inp = lambda : stdin.readline()

def main():
	s = inp()[:-1]
	n = int(inp())
	a = [0 for i in range(len(s) + 5)]
	l = map(int, inp().split())
	for b in l:
		a[b - 1] = (a[b - 1] + 1) % 2
	temp = [c for c in s]
	yet = 0
	for i in range(len(s) // 2):
		yet = (yet + a[i]) % 2
		if yet == 1:
			(temp[i], temp[len(s) - i - 1]) = (temp[len(s) - i - 1], temp[i])
	print(''.join(temp))
main()


import sys, math, bisect
sys.setrecursionlimit(10 ** 4)
from random import randint
inf = float('inf')
mod = 10 ** 9 + 7

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors

def isPrime(n, k=5):
	if n < 2:
		return True
	for i in range(0, k):
		a = randint(1, n - 1)
		if pow(a, n - 1, n) != 1:
			return False
	return True
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop, heapify
import string
s = list(input())
m = int(input())
n = len(s)
arr = list(map(int, input().split()))

def findEnd(s):
	return n - s + 1
dp = [0] * n
for i in arr:
	(start, end) = (i - 1, findEnd(i) - 1)
	dp[start] += 1
	if end != n - 1:
		dp[end + 1] = -1
for i in range(1, n):
	dp[i] += dp[i - 1]
for i in range(n // 2):
	if dp[i] % 2:
		end = findEnd(i + 1) - 1
		(s[i], s[end]) = (s[end], s[i])
print(''.join(s))


x = list(input())
l = len(x)
c = input()
lst = [0] * (l // 2 + 1)
for i in input().split():
	lst[int(i) - 1] += 1
for i in range(1, l // 2 + 1):
	lst[i] += lst[i - 1]
for i in range(l // 2):
	if lst[i] % 2 == 1:
		(x[i], x[l - i - 1]) = (x[l - i - 1], x[i])
print(''.join(x))


import string
s = list(input())
n = int(input())
c = [0] * len(s)
data = input().split()
for i in data:
	c[int(i) - 1] += 1
for i in range(len(s) // 2):
	c[i + 1] += c[i]
	if c[i] % 2 == 1:
		(s[i], s[-i - 1]) = (s[-i - 1], s[i])
for i in s:
	print(i, end='')


st = list(input())
n = int(input())
f = j = 0
a = sorted([*map(int, input().split())])
for i in range(1, len(st) // 2 + 1):
	try:
		while a[j] == i:
			f += 1
			j += 1
	except:
		pass
	if f % 2 == 1:
		(st[i - 1], st[len(st) - i]) = (st[len(st) - i], st[i - 1])
print(''.join(st))


st = str(input())
s = []
for i in range(0, 1000):
	go = 1
s = list(st)
n = int(input())
b = []
for i in range(0, 1000):
	go = 1
b = list(map(int, input().split()))
b.sort()
l = len(b)
k = len(s) - 1
for i in range(0, 1000):
	go = 1
m = int((k + 2) / 2)
for i in range(0, 1000):
	go = 1
b.append(m + 1)
while l >= 0:
	if l % 2 == 1:
		for i in range(b[l - 1] - 1, b[l] - 1):
			t = s[i]
			s[i] = s[k - i]
			s[k - i] = t
	l -= 1
for i in range(0, 1000):
	go = 1
for i in range(0, k + 1):
	print(s[i], end='')


import sys
import itertools

def swap_rev(x, i, rev):
	if rev:
		(x[i], x[len(x) - i - 1]) = (x[len(x) - i - 1], x[i])

def main():
	s = sys.stdin.readline().strip()
	result = list(s)
	sys.stdin.readline()
	m = sorted(map(int, sys.stdin.readline().split()))
	rev = False
	prev = -1
	for (day, elements) in itertools.groupby(m):
		if len(list(elements)) % 2 == 0:
			continue
		day = day - 1
		for i in range(prev + 1, day):
			swap_rev(result, i, rev)
		rev = not rev
		swap_rev(result, day, rev)
		prev = day
	for i in range(prev + 1, int((len(result) + 1) / 2)):
		swap_rev(result, i, rev)
	print(''.join(result))

def __starting_point():
	main()
__starting_point()


x = input()
m = int(input())
a1 = [int(i) - 1 for i in input().split()]
ll = len(x)
ll += ll % 2
u = ll // 2 * [0]
for i in range(m):
	u[a1[i]] += 1
for i in range(1, ll // 2):
	u[i] = u[i] + u[i - 1]
p1 = ''
p2 = ''
for i in range(len(x) // 2):
	if u[i] % 2 == 0:
		p1 += x[i]
		p2 = x[-i - 1] + p2
	else:
		p2 = x[i] + p2
		p1 += x[-i - 1]
if len(x) % 2 == 1:
	print(p1 + x[len(x) // 2] + p2)
else:
	print(p1 + p2)


s = list(input())
m = int(input())
a = list(map(int, input().split()))
x = len(s)
c = [0] * (x // 2)
for i in range(m):
	c[a[i] - 1] += 1
flag = 0
for i in range(1, x // 2):
	c[i] += c[i - 1]
for i in range(x // 2):
	if c[i] % 2 != 0:
		(s[i], s[x - i - 1]) = (s[x - i - 1], s[i])
print(''.join(map(str, s)))


s = list(input())
n = len(s) // 2
m = int(input())
arr = [int(x) for x in input().split()]
cumm = [0] * (n + 1)
for i in arr:
	cumm[i - 1] += 1
for i in range(1, n + 1):
	cumm[i] += cumm[i - 1]
for i in range(n):
	if cumm[i] % 2 == 1:
		(s[i], s[-i - 1]) = (s[-i - 1], s[i])
print(*s, sep='')


s = list(input())
n = len(s)
m = int(input())
a = list(map(int, input().split()))
l = [0] * (n + 1)
for i in a:
	l[i - 1] += 1
	l[n - i + 1] -= 1
k = 0
l2 = []
for i in range(n):
	k += l[i]
	if k % 2 == 0:
		l2.append(s[i])
	else:
		l2.append(s[n - i - 1])
print(''.join(l2))


s = [i for i in input()]
m = int(input())
arr = [int(i) for i in input().split()]
prefix = [0] * 10 ** 5
for i in arr:
	prefix[i - 1] += 1
counter = 0
i = 0
while (i + 1) * 2 <= len(s):
	counter ^= prefix[i] % 2
	if counter:
		right = len(s) - i - 1
		(s[i], s[right]) = (s[right], s[i])
	i += 1
print(*s, sep='')


s = [' '] + list(input())
L = len(s)
_ = input()
a = [0] * (L // 2 + 10)
for t in input().split():
	a[int(t)] += 1
for i in range(1, L // 2 + 1):
	a[i] += a[i - 1]
for i in range(L // 2 + 1):
	if a[i] % 2:
		(s[i], s[L - i]) = (s[L - i], s[i])
print(''.join(s[1:]))


s = input()
m = int(input())
a = list(map(int, input().split()))
l = len(s)
n = (l + 1) // 2
k = [False] * n
for i in a:
	pos = min(i, l - i + 1) - 1
	k[pos] = not k[pos]
if l % 2 == 0:
	k += [0] + k[::-1][:-1]
else:
	k += [0] + k[::-1][1:-1]
new = ''
m = False
for i in range(l):
	if k[i]:
		m = not m
	if m:
		new += s[l - i - 1]
	else:
		new += s[i]
print(new)


s = ['#'] + list(input())
input()
nums = map(int, input().split())
n = len(s)
a = [0] * (n // 2 + 1)
for x in nums:
	a[x] += 1
for i in range(1, n // 2 + 1):
	a[i] += a[i - 1]
for i in range(1, n // 2 + 1):
	if a[i] % 2 == 1:
		(s[i], s[n - i]) = (s[n - i], s[i])
print(str.join('', s[1:]))


def main():
	s = input()
	m = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	st = [0] * len(s)
	b = []
	for i in range(m):
		st[a[i] - 1] += 1
		st[len(s) - a[i]] += 1
	for i in range(len(s)):
		if i < len(s) / 2:
			count += st[i]
		if count % 2:
			b.append(s[len(s) - i - 1])
		else:
			b.append(s[i])
		if i >= len(s) / 2:
			count += st[i]
	b = ''.join(b)
	print(b)
main()


s = list(input())
m = int(input())
cnt = [0] * len(s)
for x in input().split():
	cnt[int(x) - 1] += 1
for i in range(1, len(s)):
	cnt[i] += cnt[i - 1]
for i in range(len(s) // 2):
	if cnt[i] & 1:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


s = input()
m = len(s)
n = int(input())
arr = [0 for _ in range(m + 1)]
out = list(map(int, input().split()))
for x in out:
	arr[x] = 1 + arr[x]
	if m - x + 2 <= m:
		arr[m - x + 2] -= 1
for y in range(1, m + 1):
	arr[y] = arr[y] + arr[y - 1]
out = list(s)
i = 1
while i <= m // 2:
	if arr[i] & 1:
		(out[i - 1], out[m - i]) = (out[m - i], out[i - 1])
	i += 1
print(''.join(out))


s = [''] + list(input())
n = int(input())
n = len(s)
l = n * [0]
for q in map(int, input().split()):
	l[q] += 1
for i in range(1, n // 2 + 1):
	l[i] += l[i - 1]
	if l[i] & 1:
		(s[i], s[n - i]) = (s[n - i], s[i])
print(''.join(s))


s = list(input())
m = int(input())
n = len(s)
lis = sorted(map(int, input().split()))
has = [0] * (n + 3)
for i in range(m):
	a = lis[i]
	has[a - 1] += 1
for i in range(1, n + 2):
	has[i] += has[i - 1]
for i in range(n // 2):
	if has[i] % 2:
		(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
print(''.join(s))


from sys import stdin

def main():
	s = list(input())
	m = int(stdin.readline())
	count = [0] * (len(s) + 1)
	ar = list(map(int, stdin.readline().split()))
	for tn in ar:
		count[tn] += 1
	for i in range(1, len(s) // 2 + 1):
		count[i] += count[i - 1]
	for i in range(len(s) // 2):
		if count[i + 1] % 2 == 1:
			(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
	print(''.join(s))
main()


s = list(input())
n = len(s)
m = int(input())
ai = list(map(int, input().split()))
ai.sort()
z = 0
for i in range(m):
	if i % 2 != 0:
		temp = n - ai[i]
		temp2 = n - z
		temp3 = reversed(s[z:ai[i] - 1])
		s[z:ai[i] - 1] = reversed(s[temp + 1:temp2])
		s[temp + 1:temp2] = temp3
	z = ai[i] - 1
if m % 2 != 0:
	s[ai[-1] - 1:n - ai[-1] + 1] = reversed(s[ai[-1] - 1:n - ai[-1] + 1])
print(''.join(s))


import random, math
from copy import deepcopy as dc

def randomNumber(s, e):
	return random.randint(s, e)

def randomArray(s, e, s_size, e_size):
	size = random.randint(s_size, e_size)
	arr = [randomNumber(s, e) for i in range(size)]
	return arr

def testcase():
	pass

def brute(s, m, li):
	n = len(s)
	for i in li:
		st = i - 1
		e = n - i
		s = s[:st] + s[st:e + 1][::-1] + s[e + 1:]
	return s

def effe(s, m, li):
	li.sort()
	n = len(s)
	mid = n // 2
	swapper = [0] * mid
	k = 0
	k1 = 0
	while k < mid and k1 < m:
		if k and swapper[k] <= swapper[k - 1]:
			swapper[k] = swapper[k - 1] if k else 0
		if k + 1 == li[k1]:
			k1 += 1
			swapper[k] += 1
		elif k + 1 < li[k1]:
			k += 1
		else:
			k1 += 1
	k += 1
	while k and k < mid:
		swapper[k] = swapper[k - 1]
		k += 1
	for i in range(mid):
		swapper[i] %= 2
	s = list(s)
	for i in range(mid):
		if swapper[i]:
			(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
	return ''.join(s)

def solution(s, m, li):
	return effe(s, m, li)

def input_test():
	s = input()
	m = int(input())
	li = list(map(int, input().strip().split(' ')))
	out = solution(s, m, li)
	print(out)

def test():
	pass
input_test()


(s, m, v) = (list(input()), int(input()), list(map(int, input().split())))
n = len(s)
d = [0] * (n + 2)
for i in range(m):
	d[v[i]] += 1
	d[n - v[i] + 2] -= 1
for i in range(1, n + 1):
	d[i] += d[i - 1]
	if d[i] & 1 and 2 * i <= n:
		(s[i - 1], s[n - i]) = (s[n - i], s[i - 1])
for ch in s:
	print(ch, end='')


s = list(input())
m = int(input())
s_s = [0] * len(s)
for a in map(int, input().split()):
	s_s[a - 1] += 1
cur = 0
for i in range(len(s) // 2):
	cur += s_s[i]
	if cur & 1:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


mlst = list(input())
m = int(input())
lst = [int(i) for i in input().split()]
lenmlst = len(mlst)
lst2 = []
for i in range(lenmlst + 1):
	lst2.append(0)
for i in range(m):
	start = lst[i]
	end = lenmlst - 1 - (lst[i] - 1) + 1
	lst2[start] += 1
	lst2[end] -= 1
for i in range(1, int(lenmlst / 2 + 1)):
	lst2[i] += lst2[i - 1]
	if lst2[i] % 2 != 0:
		(mlst[i - 1], mlst[lenmlst - 1 - (i - 1)]) = (mlst[lenmlst - 1 - (i - 1)], mlst[i - 1])
print(''.join(mlst))


(s, m) = (input(), int(input()))
cnt = [0] * len(s)
for x in map(int, input().split()):
	cnt[x - 1] += 1
s = [x for x in s]
cur = 0
for i in range(len(s) // 2):
	cur += cnt[i]
	if cur & 1:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
for x in s:
	print(x, end='')
print()


string = input()
string = list(string)
Slen = len(string)
m = int(input())
inline = input().split()
a = []
for i in range(m):
	a.append(int(inline[i]))
a.append(Slen // 2 + 1)
a.sort()
changes = [0 for i in range(Slen)]
flag = 0
for i in range(len(a) - 1):
	if flag == 0:
		for j in range(a[i], a[i + 1]):
			(string[j - 1], string[Slen - j - 1 + 1]) = (string[Slen - j - 1 + 1], string[j - 1])
	flag = 1 - flag
for i in range(Slen):
	print(string[i], sep='', end='')


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
int1 = lambda x: int(x) - 1

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	s = input()
	(n,) = aj()
	A = aj()
	dif = [0] * (len(s) + 1)
	for i in A:
		dif[i - 1] += 1
		dif[len(s) - i + 1] -= 1
	dif = list(accumulate(dif))
	Ans = [*s]
	for i in range(len(dif) - 1):
		if dif[i] % 2:
			(Ans[i], Ans[len(s) - i - 1]) = (Ans[len(s) - i - 1], Ans[i])
			dif[len(s) - i - 1] = 0
	print(''.join(Ans))
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
solve()


import os
from string import *
from math import *
from itertools import *
from collections import *
from re import *
from sys import *
from bisect import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')
a = input()
f = len(a)
d = {}
input()
for i in range(1, f + 1):
	d[i] = 0
for i in map(int, input().split()):
	d[i] = d[i] + 1
z = [*range(f + 1)]
t = 0
for i in range(1, 1 + f // 2):
	t += d[i]
	if t % 2:
		(z[i], z[f - i + 1]) = (z[f - i + 1], z[i])
for i in z[1:]:
	print(a[i - 1], end='')


s = input().strip()
k = int(input())
n = len(s)
a = [False for i in range(n)]
f = list(map(int, input().split()))
for i in range(k):
	f[i] -= 1
	a[f[i]] = not a[f[i]]
rev = False
b = [None for i in range(n)]
for i in range(n // 2 + 1):
	if a[i]:
		rev = not rev
	if rev:
		b[i] = s[-i - 1]
		b[-i - 1] = s[i]
	else:
		b[i] = s[i]
		b[-i - 1] = s[-i - 1]
print(*b, sep='')


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	s = [x for x in input().strip()]
	n = len(s)
	q = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	flip = [0] * (n // 2)
	for el in arr:
		flip[el - 1] ^= 1
	for i in range(1, len(flip)):
		flip[i] += flip[i - 1]
	for i in range(n // 2):
		if flip[i] & 1:
			(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
	print(''.join(s))
tt = 1
for test in range(tt):
	solve()


import math
data = list(input())
pr = [False] * math.ceil(len(data) // 2)
am = int(input())
arr = list(map(int, input().split()))
arr.sort()
prSum = False
for i in range(am):
	prSum = not prSum
	end = 0
	if i < am - 1:
		end = arr[i + 1]
	else:
		end = len(pr)
	for g in range(arr[i] - 1, end):
		pr[g] = prSum
l = len(data)
for i in range(len(pr)):
	if pr[i]:
		f = data[i]
		data[i] = data[l - i - 1]
		data[l - i - 1] = f
print(*data, sep='')


s = input()
l2 = []
for i in s:
	l2.append(i)
l = [0] * (len(s) // 2 + 1)
a = int(input())
l1 = list(map(int, input().split()))
for i in l1:
	l[i] += 1
for i in range(1, len(l)):
	l[i] = l[i] + l[i - 1]
(i, lengt) = (1, len(l) - 1)
while i <= lengt:
	if l[i] % 2 == 1:
		(l2[i - 1], l2[len(s) - i]) = (l2[len(s) - i], l2[i - 1])
	i += 1
s1 = ''.join(l2)
print(s1)


ss = input()
s = list(ss)
n = len(s)
m = int(input())
arr = list(map(int, input().split()))
pr = [0] * ((n + 1) // 2)
for i in arr:
	pr[i - 1] = pr[i - 1] + 1
pref = []
for i in range(len(pr)):
	if i == 0:
		pref.append(pr[i])
	else:
		pref.append(pref[-1] + pr[i])
for i in range(len(pref)):
	if pref[i] % 2 == 1:
		c = s[i]
		d = s[n - 1 - i]
		s[i] = d
		s[n - 1 - i] = c
for i in range(n):
	print(s[i], end='')


s = input()
m = int(input())
n = len(s)
l = (n + 1) // 2
a = [0] * l
for i in (int(x) for x in input().split()):
	a[i - 1] ^= 1
h = []
t = []
tot = 0
for i in range(l):
	tot ^= a[i]
	if tot:
		h.append(s[n - i - 1])
		t.append(s[i])
	else:
		h.append(s[i])
		t.append(s[n - i - 1])
print(''.join(h), ''.join(t[:l - n % 2][::-1]), sep='')


n = input()
b = list(n)
a = int(input())
c = list(map(int, input().split()))
d = [0] * 100001
sum1 = 0
for i in range(a):
	d[c[i]] += 1
for i in range(1, 100001):
	if d[i] % 2 != 0:
		sum1 += 1
		if sum1 % 2 != 0:
			(b[i - 1], b[len(n) - i]) = (b[len(n) - i], b[i - 1])
	elif sum1 % 2 == 1 and i <= int(len(n) / 2):
		(b[i - 1], b[len(n) - i]) = (b[len(n) - i], b[i - 1])
print(''.join(b))


import math
import random

def main(s, arr):
	r = [0] * len(s)
	for i in range(len(arr)):
		idx = arr[i] - 1
		r[idx] += 1
	for i in range(1, len(r) // 2):
		r[i] += r[i - 1]
	ans = [c for c in s]
	for i in range(len(r) // 2):
		if r[i] & 1:
			(ans[i], ans[len(s) - i - 1]) = (ans[len(s) - i - 1], ans[i])
	return ''.join(ans)
s = input()
m = int(input())
arr = list(map(int, input().split()))
print(main(s, arr))


s = list(str(input()))
m = int(input())
arr = list(map(int, input().split()))
n = len(s)
prefix = [0] * (n + 1)
mid = n // 2
for i in range(m):
	left = arr[i] - 1
	right = n - left - 1
	prefix[left] += 1
	prefix[right + 1] -= 1
for i in range(1, mid + 1):
	prefix[i] += prefix[i - 1]
for i in range(n // 2):
	if prefix[i] % 2 != 0:
		(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
print(''.join(s))


st = str(input())
s = []
s = list(st)
n = int(input())
b = []
b = list(map(int, input().split()))
b.sort()
l = len(b)
k = len(s) - 1
m = int((k + 2) / 2)
b.append(m + 1)
while l:
	if l <= 0:
		break
	if l & 1 == 1:
		for i in range(b[l - 1] - 1, b[l] - 1):
			tem = s[i]
			s[i] = s[k - i]
			s[k - i] = tem
	l -= 1
for i in range(0, k + 1):
	print(s[i], end='')


s = input()
n = len(s)
ans = ['a'] * n
if len(s) % 2 == 1:
	x = n // 2
else:
	x = n // 2 - 1
p = [0] * (x + 1)
m = int(input())
l = list(map(int, input().split()))
for i in l:
	p[i - 1] += 1
for i in range(len(p)):
	if p[i] % 2 == 0:
		p[i] = 0
	else:
		p[i] = 1
x = 0
for i in range(len(p)):
	v = p[i]
	r = v ^ x
	x = r
	if r % 2 == 1:
		(ans[i], ans[n - i - 1]) = (s[n - i - 1], s[i])
	else:
		(ans[i], ans[n - i - 1]) = (s[i], s[n - i - 1])
print(''.join(ans))


import math

def main():
	S = input()
	S = list(S)
	L = len(S)
	troca = [False for i in range(math.ceil(L / 2))]
	M = int(input())
	linha = [int(i) for i in input().split()]
	for i in range(M):
		troca[linha[i] - 1] = not troca[linha[i] - 1]
	temp = False
	for i in range(len(troca)):
		temp = temp != troca[i]
		if temp:
			temp2 = S[i]
			S[i] = S[L - 1 - i]
			S[L - 1 - i] = temp2
	print(''.join(S))
	return
main()


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
s = input().strip()
n = len(s)
m = int(input())
a = int_array()
dp = [0] * n
for i in a:
	dp[i - 1] += 1
	if n - i + 1 < n:
		dp[n - i + 1] -= 1
for i in range(1, n):
	dp[i] += dp[i - 1]
ans = [''] * n
for i in range(n):
	if dp[i] % 2 == 0:
		ans[i] = s[i]
	else:
		ans[i] = s[n - i - 1]
ans = ''.join(ans)
print(ans)


cs = list(input())
m = int(input())
is_ = list(map(int, input().split()))
c_len = len(cs)
is_.append(c_len // 2 + 1)
is_.sort()
for k in range(len(is_) - 1):
	if k % 2 == 1:
		continue
	i = is_[k] - 1
	ni = is_[k + 1] - 1
	for j in range(i, ni):
		(cs[j], cs[c_len - j - 1]) = (cs[c_len - j - 1], cs[j])
print(''.join(cs))


def swap(i, j):
	t = string[i]
	string[i] = string[j]
	string[j] = t
s = input().split()[0]
n = int(input())
a = [0]
inp = input().split()
for i in range(n):
	a.append(int(inp[i]))
a.sort()
string = dict()
for i in range(len(s)):
	string[i] = s[i]
j = len(a) - 1
for i in range(int(len(s) / 2), 0, -1):
	while a[j] > i:
		j -= 1
		if j < 0:
			break
	if a[j] <= i:
		kol = j
		if kol % 2 == 1:
			swap(i - 1, len(s) - i)
out = ''
for i in range(len(s)):
	out += string[i]
print(out)


ss = input()
s = list(ss)
n = int(input())
a = list(map(int, input().split()))
i = 0
l = len(s)
a.sort()
k = 0
for i in range(0, l // 2):
	while k < n and a[k] - 1 <= i:
		k += 1
	if k % 2 == 1:
		(s[i], s[l - i - 1]) = (s[l - i - 1], s[i])
print(''.join(s))


s = input()
s = list(s)
n = input()
l = list(map(int, input().split()))
l.sort()
x = [0] * len(s)
toggle = 1
for i in range(len(l)):
	x[l[i] - 1] += 1
for i in range(1, len(x) // 2):
	x[i] += x[i - 1]
for i in range(len(x) // 2):
	if x[i] % 2 == 1:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


st = list(input())
n = int(input())
s = [0] * len(st)
for x in input().split():
	s[int(x) - 1] += 1
for i in range(1, len(st)):
	s[i] += s[i - 1]
for i in range(len(st) // 2):
	if s[i] & 1:
		(st[i], st[len(st) - i - 1]) = (st[len(st) - i - 1], st[i])
print(''.join(st))


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
s = stdin.readline().strip()
n = len(s)
m = int(stdin.readline())
arr = [0] * (n + 1)
a = list(map(int, stdin.readline().split()))
for i in range(m):
	arr[a[i] - 1] += 1
	arr[n - a[i] + 1] -= 1
curr = 0
ans = [''] * n
for i in range(n):
	curr += arr[i]
	if curr % 2 == 0:
		ans[i] = s[i]
	else:
		ans[i] = s[n - i - 1]
print(*ans, sep='')


string = input()
n = int(input())
nums = input().split(' ')
nums = list(map(int, nums))
arr = [0] * int(len(string) / 2)
non = True
counter = 0
nums.sort()
while counter < len(nums) - 1:
	if nums[counter] == nums[counter + 1]:
		del nums[counter:counter + 2]
	else:
		counter = counter + 1
counter = 0
for x in range(int(len(string) / 2)):
	if len(nums) > counter:
		if x == nums[counter] - 1:
			if counter < len(nums) - 1:
				counter = counter + 1
			if non == True:
				non = False
			else:
				non = True
	if non:
		arr[x] = 0
	else:
		arr[x] = 1
answer = [0] * len(string)
if int(len(string) / 2) < len(string) / 2:
	answer[int(len(string) / 2)] = string[int(len(string) / 2)]
for x in range(len(arr)):
	if arr[x] == 0:
		answer[x] = string[x]
		answer[len(string) - 1 - x] = string[len(string) - 1 - x]
	else:
		answer[x] = string[len(string) - 1 - x]
		answer[len(string) - 1 - x] = string[x]
print(''.join(answer))


s = list(input())
n = int(input())
mid = int(len(s) / 2)
cnt = [0] * mid
nums = list(map(int, input().split()))
for i in range(0, n):
	cnt[nums[i] - 1] += 1
acc = 0
for i in range(0, mid):
	if acc + cnt[i] & 1 == 1:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
	acc += cnt[i]
print(''.join(s))


s = input()
m = int(input())
A = [int(c) for c in input().split()]
n = len(s)
prefix = [0 for _ in range(n // 2)]
for a in A:
	prefix[a - 1] += 1
for i in range(len(prefix) - 1):
	prefix[i + 1] += prefix[i]
string_list = list(s)
for i in range(n // 2):
	if prefix[i] % 2 == 1:
		string_list[i] = s[n - i - 1]
		string_list[n - i - 1] = s[i]
print(''.join(string_list))


from collections import *
s = list(input())
n = int(input())
l = list(map(int, input().split()))
d = defaultdict(int)
for i in l:
	d[i] += 1
c = 0
m = len(s)
for i in range(m // 2):
	c += d[i + 1]
	if c & 1:
		(s[i], s[m - i - 1]) = (s[m - i - 1], s[i])
print(''.join(s))


def main():
	import sys
	s = sys.stdin.readline().strip()
	m = int(sys.stdin.readline())
	d = [0 for i in range(len(s) + 1)]
	for i in sys.stdin.readline().split():
		d[int(i)] ^= 1
	rev = 0
	result = [i for i in s]
	for i in range(1, len(s) // 2 + 1):
		rev ^= d[i]
		if rev:
			(result[i - 1], result[len(s) - i]) = (result[len(s) - i], result[i - 1])
	print(''.join(result))
main()


s = list(input())
m = int(input())
a = [int(i) for i in input().split()]
n = len(s)
sum = [0 for i in range(n // 2)]
for i in range(m):
	sum[a[i] - 1] += 1
for i in range(1, n // 2):
	sum[i] += sum[i - 1]
for i in range(n // 2):
	if sum[i] % 2:
		temp = s[i]
		s[i] = s[n - i - 1]
		s[n - i - 1] = temp
print(''.join(s))


import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def bin_search(arr, num):
	lo = 0
	hi = len(arr) - 1
	while lo <= hi:
		if lo == hi:
			if arr[lo] <= num:
				return lo + 1
			else:
				return lo
		elif lo == hi - 1:
			if arr[hi] <= num:
				return hi + 1
			elif arr[lo] <= num:
				return lo + 1
			else:
				return lo
		mid = (lo + hi) // 2
		if arr[mid] > num:
			hi = mid
		else:
			lo = mid

def main():
	S = [c for c in line()]
	line()
	reverse = lmi(line())
	reverse.sort()
	for i in range(1, len(S) + 1):
		if i * 2 > len(S):
			break
		num = bin_search(reverse, i)
		if num % 2 == 1:
			i1 = i
			i2 = len(S) - i + 1
			(S[i1 - 1], S[i2 - 1]) = (S[i2 - 1], S[i1 - 1])
	print(jsns(S))
main()


def s():
	s = list(input())
	l = len(s) - 1
	input()
	a = list(map(int, input().split(' ')))
	a.sort()
	a.append(l // 2 + 2)
	f = False
	t = 0
	for i in a:
		if f:
			for k in range(t, i - 1):
				(s[k], s[l - k]) = (s[l - k], s[k])
		f = not f
		t = i - 1
	print(*s, sep='')
s()


s = [' '] + list(input())
m = int(input())
a = list(map(int, input().rstrip().split()))
n = len(s)
li = [0] * (n // 2 + 4)
for x in a:
	li[x] += 1
for i in range(1, n // 2 + 1):
	li[i] += li[i - 1]
for i in range(n // 2 + 1):
	if li[i] & 1:
		(s[i], s[n - i]) = (s[n - i], s[i])
print(''.join(s[1:]))


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
	string = list(input().replace('\n', ''))
	n = len(string)
	mask = [0 for _ in range(n)]
	m = int(input())
	for a_i in read_tuple(int):
		mask[a_i - 1] += 1
	inversions = 0
	for i in range(n // 2):
		inversions += mask[i]
		if inversions % 2:
			(string[i], string[n - i - 1]) = (string[n - i - 1], string[i])
	print(''.join(string))
solve()


s = input()
m2 = int(input())
a = list(map(int, input().split()))
m = {}
m1 = set()
for i in range(m2):
	if a[i] not in m1:
		m1.add(a[i])
		m[a[i]] = 1
	else:
		m[a[i]] += 1
if 1 in m1:
	k = [m[1]]
else:
	k = [0]
for i in range(1, len(s) // 2):
	if i + 1 in m1:
		k.append(k[-1] + m[i + 1])
	else:
		k.append(k[-1])
s1 = []
for i in range(len(s)):
	s1.append(s[i])
for i in range(len(s) // 2):
	if k[i] % 2 == 1:
		t = s1[len(s) - i - 1]
		s1[len(s) - i - 1] = s[i]
		s1[i] = t
for i in range(len(s1)):
	print(s1[i], end='')


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def pref(a, n, f):
	pre = [0] * n
	if f == 0:
		pre[0] = a[0]
		for i in range(1, n):
			pre[i] = a[i] + pre[i - 1]
	else:
		pre[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			pre[i] = pre[i + 1] + a[i]
	return pre
s1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
s2 = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(1):
	s = sin().strip()
	m = inin()
	l = ain()
	n = len(s)
	ans = [0] * n
	for i in l:
		ans[i - 1] += 1
		if n - i + 1 < n:
			ans[n - i + 1] -= 1
	pre = pref(ans, n, 0)
	for i in range(n // 2 + 1):
		if pre[i] % 2 == 0:
			ans[i] = s[i]
			ans[n - i - 1] = s[n - i - 1]
		else:
			(ans[i], ans[n - i - 1]) = (s[n - i - 1], s[i])
	print(''.join([str(i) for i in ans]))


import sys
f = sys.stdin.readline
s = list(f().strip())
m = int(f().strip())
arr = [int(v) for v in f().strip().split()]
a = [0] * (len(s) + 1)
for v in arr:
	a[v - 1] += 1
	a[len(s) - v + 1] -= 1
for i in range(1, len(s) + 1):
	a[i] += a[i - 1]
for i in range(len(s) // 2):
	if a[i] % 2 != 0:
		(s[i], s[len(s) - 1 - i]) = (s[len(s) - 1 - i], s[i])
print(''.join(s))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
s = list(input())
(m,) = Neo()
A = Neo()
n = len(s)
mark = [0] * (n + 1)
for i in A:
	l = i - 1
	r = n - i - 1
	mark[l] += 1
	mark[r + 1] -= 1
mark = list(accumulate(mark))
for i in range(n // 2):
	if mark[i] % 2:
		(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
print(''.join(s))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 99999999999999999999999999999999

def outIn(x):
	print(x, flush=True)
	return input()

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		s = rs()
		ans = list(s)
		n = len(s)
		m = ri()
		rangcalc = [0] * (n + 5)
		a = ria()
		for i in a:
			l = i - 1
			r = n - i
			rangcalc[l] += 1
			rangcalc[r + 1] -= 1
		s = 0
		for i in range(1, n + 5):
			rangcalc[i] += rangcalc[i - 1]
		for i in range(n // 2):
			if rangcalc[i] % 2:
				(ans[i], ans[n - i - 1]) = (ans[n - 1 - i], ans[i])
		ws(''.join(ans))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


def fun(s, m, arr):
	n = len(s)
	s = list(s)
	li = [0] * (n // 2)
	for i in arr:
		li[i - 1] += 1
	for i in range(1, len(li)):
		li[i] = li[i - 1] + li[i]
	for i in range(n // 2 - 1, -1, -1):
		if li[i] & 1:
			(s[i], s[n - i - 1]) = (s[n - i - 1], s[i])
	return ''.join(s)
s = input()
m = int(input())
arr = list(map(int, input().split()))
print(fun(s, m, arr))


x = input()
l = len(x)
a = int(input())
b = list(map(int, input().split(' ')))
b.sort()
sumx = [0] * len(x) + [0]
pt = 0
for i in range(1, l // 2 + 1):
	t = 0
	if pt < len(b):
		while b[pt] == i:
			pt += 1
			t += 1
			if not pt < len(b):
				break
	sumx[i] = sumx[i - 1] + t
sumx = sumx[1:]
tt = sumx[:len(sumx) // 2]
tt.reverse()
if l % 2 == 1:
	sumx = sumx[:len(sumx) // 2] + [0] + tt
else:
	sumx = sumx[:len(sumx) // 2] + tt
strx = ''
for i in range(l):
	if sumx[i] % 2 == 1:
		strx += x[l - 1 - i]
	else:
		strx += x[i]
print(strx)


from sys import stdin

def read():
	return map(int, stdin.readline().split())
s = stdin.readline()[:-1]
read()
n = len(s)
cnt = [0] * n
for x in read():
	cnt[min(x, n - x + 1) - 1] += 1
for i in range(1, n):
	cnt[i] += cnt[i - 1]
ans = ['?'] * n
for i in range(n):
	if cnt[min(i, n - i - 1)] % 2 == 0:
		ans[i] = s[i]
	else:
		ans[i] = s[n - i - 1]
print(''.join(ans))


from sys import stdout
s = input()
d = {0: 0}
q = int(input())
l = [int(x) for x in input().split()]
for a in l:
	if a > len(s) // 2:
		a = len(s) - a + 1
	if a in d:
		d[a] += 1
	else:
		d[a] = 1
ar = []
temp = 0
for i in range(len(s) // 2):
	if i + 1 in d:
		temp += d[i + 1]
	ar.append(temp)
ans = [0] * len(s)
for i in range(len(ar)):
	if ar[i] % 2 == 0:
		ans[i] = s[i]
		ans[len(s) - i - 1] = s[len(s) - i - 1]
	else:
		ans[i] = s[len(s) - i - 1]
		ans[len(s) - i - 1] = s[i]
final = ''
for i in range(len(ans)):
	if ans[i] == 0:
		final += s[i]
	else:
		final += ans[i]
stdout.write(final)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
s = list(input())
n = Int()
a = array()
status = [0] * (len(s) // 2)
for i in a:
	status[i - 1] += 1
change = [status[0]]
for i in range(1, len(status)):
	change.append(change[-1] + status[i])
n = len(s)
for i in range(n // 2):
	if change[i] % 2:
		(s[i], s[n - 1 - i]) = (s[n - 1 - i], s[i])
print(*s, sep='')


import math
s = list(input())
a = len(s)
n = int(input())
l = list(map(int, input().split()))
k = [0] * math.ceil(a / 2)
for i in l:
	k[i - 1] += 1
b = 0
for i in range(math.ceil(a / 2)):
	b += k[i]
	if b % 2 == 1:
		(s[i], s[a - i - 1]) = (s[a - i - 1], s[i])
print(''.join(s))


from collections import Counter
s = input()
n = int(input())
positions = [int(n) - 1 for n in input().split()]
lookup = Counter()
for pos in positions:
	lookup[pos] = (lookup[pos] + 1) % 2
new_s = list(s)
(lp, rp) = (0, len(s) - 1)
last = 0
for i in range((len(s) - 1) // 2 + 1):
	cur_state = (lookup[i] + last) % 2
	if cur_state == 0:
		new_s[lp] = s[i]
		new_s[rp] = s[len(s) - 1 - i]
	else:
		new_s[rp] = s[i]
		new_s[lp] = s[len(s) - 1 - i]
	(lp, rp) = (lp + 1, rp - 1)
	last = cur_state
print(''.join(new_s))


from sys import stdin
from math import ceil
s = stdin.readline()
s = s[:len(s) - 1]
l = len(s)
n = int(stdin.readline())
m = map(int, stdin.readline().split())
arr = [0] * 200100
for a in m:
	arr[a - 1] += 1
for i in range(l - 1):
	arr[i + 1] += arr[i]
ans = [''] * l
for i in range(ceil(l / 2)):
	if arr[i] % 2:
		ans[i] = s[l - i - 1]
		ans[l - i - 1] = s[i]
	else:
		ans[i] = s[i]
		ans[l - i - 1] = s[l - i - 1]
print(''.join(ans))


s = input()
n = len(s)
m = int(input())
a = []
ss = input()
for x in ss.split(' '):
	a.append(int(x) - 1)
a.append(n // 2)
s = list(s)
a.sort()
for i in range(0, m):
	if i % 2 == 0:
		for j in range(a[i], a[i + 1]):
			(s[j], s[n - j - 1]) = (s[n - j - 1], s[j])
print(''.join(s))


s = list(input())
n = int(input())
sums = [0] * len(s)
changes = list(map(int, input().split()))
for i in range(n):
	start = changes[i - 1] - 1
	sums[start] = sums[start] + 1
swap = False
for i in range(len(s) // 2):
	if sums[i] % 2 == 1 and (not swap) or (sums[i] % 2 == 0 and swap):
		swap = True
	else:
		swap = False
	if swap:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


s = input()
m = int(input())
a = list(map(int, input().split()))
n = len(s)
flip = [0 for i in range(n)]
for x in a:
	x -= 1
	flip[x] ^= 1
	if x > 0:
		flip[n - x] ^= 1
for i in range(1, n):
	flip[i] ^= flip[i - 1]
ans = ['a' for i in range(n)]
for i in range(n):
	if flip[i] == 1:
		ans[i] = s[n - i - 1]
	else:
		ans[i] = s[i]
print(''.join(ans))


s = list(input())
m = input()
a = sorted(list(map(int, input().split())), reverse=False)
s = [''] + s
d = [0] * (2 * len(s))
for i in a:
	d[i] += 1
for i in range(2, len(s) // 2 + 1):
	d[i] += d[i - 1]
for i in range(1, (len(s) - 1) // 2 + 1):
	if d[i] % 2 == 1:
		(s[i], s[len(s) - 1 - i + 1]) = (s[len(s) - 1 - i + 1], s[i])
print(''.join(s[1:]))


s = [i for i in input()]
n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
r = 0
j = 0
for i in range(len(s) // 2):
	while j < n and arr[j] <= i + 1:
		r += 1
		j += 1
	if r % 2 == 1:
		(s[i], s[-i - 1]) = (s[-i - 1], s[i])
print(''.join(s))


read = lambda : map(int, input().split())
s = input()
m = int(input())
a = [int(i) - 1 for i in input().split()]
n = len(s)
c = [0] * (n + 1)
for i in a:
	c[i] += 1
mid = n // 2
cnt = 0
ans = list(s)
for i in range(mid):
	cnt += c[i]
	if cnt % 2:
		(ans[i], ans[n - i - 1]) = (ans[n - i - 1], ans[i])
print(''.join(ans))


st = input()
ln = len(st)
switches = [0 for i in range(ln)]
answer = [0 for i in range(ln)]
m = int(input())
arr = input().split()
arr = [int(i) for i in arr]
for val in arr:
	index = val - 1
	switches[index] = 1 - switches[index]
for i in range(ln // 2):
	if switches[i] == 1:
		answer[i] = st[ln - i - 1]
		answer[ln - i - 1] = st[i]
		switches[i + 1] = 1 - switches[i + 1]
	else:
		answer[i] = st[i]
		answer[ln - i - 1] = st[ln - i - 1]
if ln % 2 == 1:
	answer[ln // 2] = st[ln // 2]
print(''.join(answer))


s = list(input())
m = int(input())
a = list(map(int, input().split()))
swap = False
a.sort()
(i, j) = (0, 0)
for i in range(len(s) // 2):
	while j < m and a[j] - 1 <= i:
		swap = not swap
		j += 1
	if swap:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


(s, n) = (list(input()), int(input()))
a = [int(x) - 1 for x in input().split()]
l = [0] * ((len(s) + 1) // 2)
for i in a:
	l[i] += 1
k = 0
ans = ['-'] * len(s)
for i in range((len(s) + 1) // 2):
	k += l[i]
	if not k % 2:
		(ans[i], ans[-i - 1]) = (s[i], s[-i - 1])
	else:
		(ans[i], ans[-i - 1]) = (s[-i - 1], s[i])
print(''.join(ans))


from sys import stdin, stdout
s = list(stdin.readline().strip())
req = [0] * (len(s) // 2)
m = int(stdin.readline().strip())
arr = [int(num) for num in stdin.readline().strip().split()]
for i in range(m):
	req[arr[i] - 1] += 1
prev = req[0]
for i in range(1, len(s) // 2):
	req[i] += prev
	prev = req[i]
l = len(s) // 2 - 1
r = l + 1 if len(s) % 2 == 0 else l + 2
i = len(s) // 2 - 1
while i >= 0:
	if req[i] % 2 != 0:
		(s[l], s[r]) = (s[r], s[l])
	l -= 1
	r += 1
	i -= 1
stdout.write(''.join(s))


import math
s = input()
m = int(input())
l = list(map(int, input().split()))
for i in range(len(l)):
	l[i] -= 1
n = len(s)
q = [0] * n
ans = list(s)
p = ['#'] * n
for i in range(len(l)):
	if p[l[i]] == '#':
		p[l[i]] = l[i]
	else:
		p[l[i]] = '#'
c = 0
for i in range(len(q)):
	if p[i] != '#':
		c += 1
		q[i] = c % 2
	else:
		q[i] = c % 2
for i in range(int(math.ceil(len(q) / 2))):
	if q[i] == 1:
		(ans[i], ans[n - i - 1]) = (ans[n - i - 1], ans[i])
print(''.join(ans))


s = list(input())
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= 1
a = sorted(a)

def lower_bound(k):
	l = -1
	r = n - 1
	while l < r:
		md = (l + r + 1) // 2
		if a[md] <= k:
			l = md
		else:
			r = md - 1
	return l
for i in range(len(s) // 2):
	if (lower_bound(i) + 1) % 2 == 1:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


import copy
st = input()
m = int(input())
in_arr = list(map(int, input().split()))
list_st = list(st)
n = len(st)
arr = [0] * (n // 2 + 1)
for i in in_arr:
	arr[i] += 1
for i in range(1, n // 2 + 1):
	arr[i] += arr[i - 1]
	if arr[i] % 2 == 1:
		temp = copy.deepcopy(list_st[i - 1])
		list_st[i - 1] = copy.deepcopy(list_st[n - i])
		list_st[n - i] = temp
print(''.join(list_st))


s = input()
n = int(input())
arr = list(map(int, input().split(' ')))
arr = sorted(arr)
stringlist = list(s)
for i in range(n):
	if i == n - 1:
		if n % 2 == 1:
			index = arr[i] - 1
			s1 = stringlist[:index]
			stemp = stringlist[index:len(s) - index]
			s2 = stemp[::-1]
			s3 = stringlist[len(s) - index:]
			stringlist = s1 + s2 + s3
	elif arr[i] != arr[i + 1]:
		if i % 2 == 0:
			index = arr[i] - 1
			index2 = arr[i + 1] - 1
			for j in range(index, index2):
				(stringlist[len(s) - j - 1], stringlist[j]) = (stringlist[j], stringlist[len(s) - j - 1])
s = ''.join(stringlist)
print(s)


def mp(c):
	return int(c) - 1
s = list(input())
n = len(s)
m = int(input())
arr = list(map(mp, input().split()))
arr.sort()
st = []
for c in arr:
	if st and c == st[-1]:
		st.pop()
	else:
		st.append(c)
while len(st) > 1:
	a = st.pop(0)
	b = st.pop(0)
	a2 = n - 1 - a
	while a < b:
		(s[a], s[a2]) = (s[a2], s[a])
		a += 1
		a2 -= 1
if st:
	a = st.pop()
	b = n - 1 - a
	s[a:b + 1] = s[a:b + 1][::-1]
print(''.join(s))


import sys
x = input()
l = len(x)
a = int(input())
b = map(int, sys.stdin.readline().split())
rv = [False] * (l // 2 + 1)
for i in b:
	rv[i] = not rv[i]
sumx = [0] * len(x) + [0]
pt = 0
for i in range(1, l // 2 + 1):
	sumx[i] = sumx[i - 1] + rv[i]
for i in range(l // 2):
	if sumx[i + 1] % 2 == 1:
		print(x[l - 1 - i], end='')
	else:
		print(x[i], end='')
if l % 2 == 1:
	print(x[l // 2], end='')
for i in range(l // 2, l):
	if i == l // 2 and l % 2 == 1:
		continue
	if sumx[l - i] % 2 != 1:
		print(x[i], end='')
	else:
		print(x[l - 1 - i], end='')


s = list(input())
n = int(input())
l = list(map(int, input().split()))
cur = 0
mid = len(s) // 2
sum = [0] * (mid + 1)
for i in l:
	sum[i - 1] += 1
for i in range(mid):
	cur += sum[i]
	if cur % 2 != 0:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
print(''.join(s))


def main():
	s = input()
	s = [s[i] for i in range(len(s))]
	m = int(input())
	a = [int(x) for x in input().split()]
	b = [0 for i in range(int(len(s) / 2 + 1))]
	for i in range(m):
		b[a[i] - 1] += 1
	for i in range(0, int(len(s) / 2)):
		if i > 0:
			b[i] += b[i - 1]
		if b[i] % 2 == 1:
			(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
	return ''.join(s)
print(main())


s = input()
n = len(s)
pref = [0] * (n + 1)
m = int(input())
for x in input().split():
	x = int(x)
	x -= 1
	pref[x] += 1
	pref[n - x] -= 1
cnt = 0
for i in range(n):
	cnt += pref[i]
	if cnt % 2 == 0:
		print(s[i], end='')
	else:
		print(s[n - i - 1], end='')


wc = input()
n = len(wc)
w = [wc[i] for i in range(n)]
m = int(input())
cnt = [0 for i in range(n + 3)]
y = [int(x) for x in input().split()]
for i in range(m):
	x = y[i]
	cnt[x] += 1
	cnt[n - x + 2] -= 1
for i in range(n + 1):
	if i > 0:
		cnt[i] += cnt[i - 1]
for i in range(1, n + 1, 1):
	if n - i + 1 <= i:
		break
	if cnt[i] % 2 == 1:
		a = i - 1
		b = n - i
		tmp = w[a]
		w[a] = w[b]
		w[b] = tmp
for i in range(n):
	print(w[i], end='')
print()


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
s = list(input())
n = int(input())
l = len(s)
arr = list(map(int, input().split()))
mask = [0 for i in range(l)]
for i in arr:
	mask[i - 1] += 1
inver = 0
for i in range(l // 2):
	inver += mask[i]
	if inver % 2:
		(s[i], s[l - i - 1]) = (s[l - i - 1], s[i])
print(''.join(s))


str = list(input())
len = len(str)
input()
a = [0] * (len // 2 + 1)
for ai in map(int, input().split()):
	a[ai] += 1
for i in range(1, len // 2 + 1):
	a[i] += a[i - 1]
	if a[i] % 2 == 1:
		(str[i - 1], str[len - i]) = (str[len - i], str[i - 1])
print(''.join(str))


import sys
input = sys.stdin.readline

def multi_input():
	return map(int, input().split())

def array_print(arr):
	print(''.join(map(str, arr)))
s = list(input())
s.pop(-1)
n = int(input())
a = list(multi_input())
b = [0] * len(s)
for i in range(n):
	b[a[i] - 1] += 1
for i in range(len(s) // 2):
	if i != 0:
		b[i] += b[i - 1]
	if b[i] % 2 != 0:
		(s[i], s[len(s) - i - 1]) = (s[len(s) - i - 1], s[i])
array_print(s)


temp = list(input())
m = int(input())
trans = [int(x) for x in input().split()]
trans.sort()
n = len(temp)
k = 0
for i in range(n // 2):
	while k < m and trans[k] - 1 <= i:
		k += 1
	if k % 2 == 1:
		(temp[i], temp[n - i - 1]) = (temp[n - i - 1], temp[i])
print(''.join(temp))


from collections import Counter
arr = list(input())
m = int(input())
s = list(map(int, input().split()))
n = len(arr)
sum_arr = [0] * n
for i in s:
	sum_arr[i - 1] += 1
if sum_arr[0] % 2 != 0:
	(arr[0], arr[-1]) = (arr[-1], arr[0])
for i in range(1, len(arr) // 2):
	sum_arr[i] += sum_arr[i - 1]
	if sum_arr[i] % 2 != 0:
		(arr[i], arr[-i - 1]) = (arr[-i - 1], arr[i])
print(''.join(arr))