#include<iostream>
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;

typedef long long ll;

long long _e9 = 1e9;
ll n,d;

const double pi = 3.14159265359;

int main()
{
    cin >> n;
    if(n==1) { cout << 0; }
    else
    {
        vector< double > A(n);
        for(int i=0;i<n;++i)
        {
            double x,y,ang = 0;
            cin >> x >> y;
            if(x==0) ang = pi/2;
            else if(y==0) ang = 0;
            else ang = atan2(abs(y),abs(x));
            if(x<0) ang = pi-ang;
            if(y<0) ang = pi*2-ang;
            A[i] = ang;
        }
        sort(A.begin(),A.end());
        double ans = pi*2;
        if(n==2) ans = min(A[1]-A[0],pi*2-(A[1]-A[0]));
        else
        {
            for(int i=0;i<n-1;++i)
            {
                ans = min(ans,pi*2 -(A[i+1]-A[i]));
            }
            ans = min(ans,A[n-1]-A[0]);
        }
        cout << fixed << setprecision(9) << ans*180/pi;
    }

    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std ;
int main ()
{
	string in ;
	cin >> in ;

	int end , m , start , thelenth = in.length() ;
	cin >> m ;

	for ( int i = 0 ; i < m ; i ++)
	{
		cin >> start ;
		if ( (start *2) <= thelenth )
		{
			end = thelenth - start + 1 ;
			start = start - 1 ;

			string::iterator S = in.begin() ;
			string::iterator E = in.end() ;

			S += start ;
			E = in.begin() + end ;

			reverse(S , E);
		}
		else
			continue;
	}

	cout << in << endl ;

	return 0;
 }


#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std ;
int main ()
{
	string in ;
	cin >> in ;

	int  start , thelenth = in.length() ;
	cin >> start ;

	vector<int> V ( thelenth ) ;
	for ( int i = 0 ; i < start ; i++)
	{
		int val ;
		cin >> val ;
		V[val-1] = 1 ;
	}
	int sum = 0 ;
	for ( int i = 0 ; i < thelenth/2 ; i++)
	{
		sum += V[i] ;
		if ( sum % 2 == 0 )
			continue;
		else
		{
			int equ = (thelenth-1) - (i+1) ;
			char temp = in[i] ;
			in[i] = in[equ-1] ;
			in[equ-1] = temp ;
		}
	}
	cout << in << endl ;

	return 0;
 }


#include <bits/stdc++.h>

using namespace std;
typedef struct item * pitem;
struct item {
	int prior, cnt;
	char value;
	bool rev;
    item() {}
    item(char _val): value(_val) {
        for (int i = 0; i < 3; ++i) {
            prior <<= 16;
            prior += rand() & 0xFFFF;
        }
        cnt = 1;
        l = r = NULL;
    }
	pitem l, r;
};

int cnt (pitem it) {
	return it ? it->cnt : 0;
}

void upd_cnt (pitem it) {
	if (it)
		it->cnt = cnt(it->l) + cnt(it->r) + 1;
}

void push (pitem it) {
	if (it && it->rev) {
		it->rev = false;
		swap (it->l, it->r);
		if (it->l)  it->l->rev ^= true;
		if (it->r)  it->r->rev ^= true;
	}
}

void merge (pitem & t, pitem l, pitem r) {
	push (l);
	push (r);
	if (!l || !r)
		t = l ? l : r;
	else if (l->prior > r->prior)
		merge (l->r, l->r, r),  t = l;
	else
		merge (r->l, l, r->l),  t = r;
	upd_cnt (t);
}

void split (pitem t, pitem & l, pitem & r, int key, int add = 0) {
	if (!t)
		return void( l = r = 0 );
	push (t);
	int cur_key = add + cnt(t->l);
	if (key <= cur_key)
		split (t->l, l, t->l, key, add),  r = t;
	else
		split (t->r, t->r, r, key, add + 1 + cnt(t->l)),  l = t;
	upd_cnt (t);
}

void reverse (pitem t, int l, int r) {
	pitem t1, t2, t3;
	split (t, t1, t2, l);
	split (t2, t2, t3, r-l+1);
	t2->rev ^= true;
	merge (t, t1, t2);
	merge (t, t, t3);
}

void output (pitem t) {
	if (!t)  return;
	push (t);
	output (t->l);
	//printf ("%d ", t->value);
    cout << t->value;
	output (t->r);
}

void insert (item * & t, item * it, int cn)
{
	if (!t)
		t = it;
	else if (it->prior > t->prior)
		split (t, it->l, it->r, cn),  t = it;
	else
		insert (cn < t->cnt ? t->l : t->r, it, cn);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    item * t = NULL;
    int n, m;
    //cin >> n >> m;
    string s;
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
    {
     //   cin >> s[i];
        insert(t, new item(s[i]), i);
    }
    cin >> m;
    //write(t);
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l;
        r = n - l + 1;
        reverse(t, l - 1 , r - 1);
        //write(t);
    }
   // write(t);
    output(t);
    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef struct item * pitem;
struct item {
	int prior, cnt;
	char value;
	bool rev;
    item() {}
    item(char _val): value(_val)
    {
        for (int i = 0; i < 3; ++i) {
            prior <<= 16;
            prior += rand() & 0xFFFFFF;
        }
        cnt = 1;
        l = r = NULL;
    }
	pitem l, r;
};

int cnt (pitem it) {
	return it ? it->cnt : 0;
}

void upd_cnt (pitem it) {
	if (it)
		it->cnt = cnt(it->l) + cnt(it->r) + 1;
}

void push (pitem it) {
	if (it && it->rev) {
		it->rev = false;
		swap (it->l, it->r);
		if (it->l)  it->l->rev ^= true;
		if (it->r)  it->r->rev ^= true;
	}
}

void merge (pitem & t, pitem l, pitem r) {
	push (l);
	push (r);
	if (!l || !r)
		t = l ? l : r;
	else if (l->prior > r->prior)
		merge (l->r, l->r, r),  t = l;
	else
		merge (r->l, l, r->l),  t = r;
	upd_cnt (t);
}

void split (pitem t, pitem & l, pitem & r, int key, int add = 0) {
	if (!t)
		return void( l = r = 0 );
	push (t);
	int cur_key = add + cnt(t->l);
	if (key <= cur_key)
		split (t->l, l, t->l, key, add),  r = t;
	else
		split (t->r, t->r, r, key, add + 1 + cnt(t->l)),  l = t;
	upd_cnt (t);
}

void reverse (pitem t, int l, int r) {
	pitem t1, t2, t3;
	split (t, t1, t2, l);
	split (t2, t2, t3, r - l + 1);
	t2->rev ^= true;
	merge (t, t1, t2);
	merge (t, t, t3);
}

void output (pitem t) {
	if (!t)  return;
	push (t);
	output (t->l);
	//printf ("%d ", t->value);
    cout << t->value;
	output (t->r);
}

void insert (item * & t, item * it, int cn)
{
	if (!t)
		t = it;
	else if (it->prior > t->prior)
		split (t, it->l, it->r, cn),  t = it;
	else
		insert (cn < t->cnt ? t->l : t->r, it, cn);
}

main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    item * t = NULL;
    int n, m;
    //cin >> n >> m;
    string s;
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
    {
        insert(t, new item(s[i]), i);
    }
    cin >> m;
    //write(t);
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l;
        r = n - l + 1;
        reverse(t, l - 1 , r - 1);
        //write(t);
   // write(t);
    }
    output(t);

    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef struct item * pitem;
struct item {
	int prior, cnt;
	char value;
	bool rev;
    item() {}
    item(char _val): value(_val)
    {
        for (int i = 0; i < 3; ++i) {
            prior <<= 16;
            prior += rand() & 0xFFFF;
        }
        cnt = 1;
        l = r = NULL;
    }
	pitem l, r;
};

int cnt (pitem it) {
	return it ? it->cnt : 0;
}

void upd_cnt (pitem it) {
	if (it)
		it->cnt = cnt(it->l) + cnt(it->r) + 1;
}

void push (pitem it) {
	if (it && it->rev) {
		it->rev = false;
		swap (it->l, it->r);
		if (it->l)  it->l->rev ^= true;
		if (it->r)  it->r->rev ^= true;
	}
}

void merge (pitem & t, pitem l, pitem r) {
	push (l);
	push (r);
	if (!l || !r)
		t = l ? l : r;
	else if (l->prior > r->prior)
		merge (l->r, l->r, r),  t = l;
	else
		merge (r->l, l, r->l),  t = r;
	upd_cnt (t);
}

void split (pitem t, pitem & l, pitem & r, int key, int add = 0) {
	if (!t)
		return void( l = r = 0 );
	push (t);
	int cur_key = add + cnt(t->l);
	if (key <= cur_key)
		split (t->l, l, t->l, key, add),  r = t;
	else
		split (t->r, t->r, r, key, add + 1 + cnt(t->l)),  l = t;
	upd_cnt (t);
}

void reverse (pitem t, int l, int r) {
	pitem t1, t2, t3;
	split (t, t1, t2, l);
	split (t2, t2, t3, r - l + 1);
	t2->rev ^= true;
	merge (t, t1, t2);
	merge (t, t, t3);
}

void output (pitem t) {
	if (!t)  return;
	push (t);
	output (t->l);
	//printf ("%d ", t->value);
    cout << t->value;
	output (t->r);
}

void insert (item * & t, item * it, int cn)
{
	if (!t)
		t = it;
	else if (it->prior > t->prior)
		split (t, it->l, it->r, cn),  t = it;
	else
		insert (cn < t->cnt ? t->l : t->r, it, cn);
}

main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    item * t = NULL;
    int n, m;
    //cin >> n >> m;
    string s;
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
    {
        insert(t, new item(s[i]), i);
    }
    cin >> m;
    //write(t);
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l;
        r = n - l + 1;
        reverse(t, l - 1 , r - 1);
        //write(t);
   // write(t);
    }
    output(t);

    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef struct item * pitem;
struct item {
	int prior, cnt;
	char value;
	bool rev;
    item() {}
    item(char _val): value(_val)
    {
        for (int i = 0; i < 3; ++i) {
            prior <<= 16;
            prior += rand() & 0xFFFF;
        }
        cnt = 1;
        l = r = NULL;
    }
	pitem l, r;
};

int cnt (pitem it) {
	return it ? it->cnt : 0;
}

void upd_cnt (pitem it) {
	if (it)
		it->cnt = cnt(it->l) + cnt(it->r) + 1;
}

void push (pitem it) {
	if (it && it->rev) {
		it->rev = false;
		swap (it->l, it->r);
		if (it->l)  it->l->rev ^= true;
		if (it->r)  it->r->rev ^= true;
	}
}

void merge (pitem & t, pitem l, pitem r) {
	push (l);
	push (r);
	if (!l || !r)
		t = l ? l : r;
	else if (l->prior > r->prior)
		merge (l->r, l->r, r),  t = l;
	else
		merge (r->l, l, r->l),  t = r;
	upd_cnt (t);
}

void split (pitem t, pitem & l, pitem & r, int key, int add = 0) {
	if (!t)
		return void( l = r = 0 );
	push (t);
	int cur_key = add + cnt(t->l);
	if (key <= cur_key)
		split (t->l, l, t->l, key, add),  r = t;
	else
		split (t->r, t->r, r, key, add + 1 + cnt(t->l)),  l = t;
	upd_cnt (t);
}

void reverse (pitem t, int l, int r) {
	pitem t1, t2, t3;
	split (t, t1, t2, l);
	split (t2, t2, t3, r - l + 1);
	t2->rev ^= true;
	merge (t, t1, t2);
	merge (t, t, t3);
}

void output (pitem t) {
	if (!t)  return;
	push (t);
	output (t->l);
	//printf ("%d ", t->value);
    cout << t->value;
	output (t->r);
}

void insert (item * & t, item * it, int cn)
{
	if (!t)
		t = it;
	else if (it->prior > t->prior)
		split (t, it->l, it->r, cn),  t = it;
	else
		insert (cn < t->cnt ? t->l : t->r, it, cn);
}

main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    item * t = NULL;
    int n, m;
    //cin >> n >> m;
    string s;
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
    {
        insert(t, new item(s[i]), i);
    }
    cin >> m;
    //write(t);
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l;
        r = n - l + 1;
        reverse(t, l - 1 , r - 1);
        //write(t);
    }
   // write(t);
    output(t);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int MAX = 2e5 + 10;
int d[MAX];

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        d[a - 1]++;
    }
    vector <char> ans(n);

    int bal = 0;
    for (int i = 0; i < s.length() / 2 + 1; i++)
    {
        bal += d[i];
        //cout << bal << endl;
        if (bal % 2 == 1)
            ans[n - i - 1] = s[i], ans[i] = s[n - i - 1];
        else
            ans[n - i - 1] = s[n - i - 1], ans[i] = s[i];
    }
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i];
}


#include <bits/stdc++.h>

using namespace std;
const int MAX = 2e5 + 10;
int d[MAX];

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        d[a - 1]++;
    }
    vector <char> ans(n);

    int bal = 0;
    for (int i = 0; i < s.length() / 2; i++)
    {
        bal += d[i];
        //cout << bal << endl;
        if (bal % 2 == 1)
            ans[n - i - 1] = s[i], ans[i] = s[n - i - 1];
        else
            ans[n - i - 1] = s[n - i - 1], ans[i] = s[i];
    }
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i];
}


#include <bits/stdc++.h>
using namespace std;
long long cnt[500000], j = 1, m;
int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s;
	cin >> s >> m;
	for (long long i = 0; i < m; i++){
		long long a;
		cin >> a;
		cnt[a - 1]++;
	}
	for (long long i = 0; i < (s.size() + 1)/2; i++){
		if (cnt[i] %2 == j)
			swap(s[i], s[s.size() - i - 1]);
		j = cnt[i] > 0 ? -j + 1 : j;
	}
	cout << s;
}


#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define pb push_back
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN =1e5+100 ;
ll a[MAXN] , m , sum[MAXN];
bool mark[MAXN] ;

int main ()
{
	boost ;
	string s ;

	cin >> s >> m ;
	s = " " + s ;
	ll n = s.size() ;

	for(ll i=1 ; i<=m ; i++)
	{
		cin >> a[i] ;
		if(mark[a[i]])
			mark[a[i]] = 0 ;
		else
			mark[a[i]] = 1 ;
	}
	sum[0] = 0;
	for(ll i=1 ;i<=n/2 ; i++)
	{
		sum[i] = sum[i-1] + mark[i] ;
	}
	for(ll i=1 ; i<=n/2 ; i++)
	{
//		cout << sum[i] << " " << mark[i] << endl ;
		if(sum[i] % 2 == 1)
			swap(s[i] , s[n-i]) ;
	}
	for(ll i=1 ; i<n ; i++)
		cout <<s[i] ;
}


#include <bits/stdc++.h>
using namespace std;
int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		int a;
		cin >> a;
		for (int i = a - 1; i < (s.size() + 1) / 2; i ++)
			swap(s[i], s[s.size() - i - 1]);
	}
	cout << s;
}


#include <bits/stdc++.h>
using namespace std;
int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int m;
	cin >> m;
	while (m--)
	{
		int a;
		cin >> a;
		for (int i = a - 1; i < (s.size() + 1) / 2; i ++)
			swap(s[i], s[s.size() - i - 1]);
	}
	cout << s;
}


#include <bits/stdc++.h>
using namespace std;
int cnt[500000];
int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int m;
	cin >> m;
	int a[m];
	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 0; i < m; i++)
	{
		if (cnt[a[i]] %2 == 1)
			for (int j = a[i] - 1; j < (s.size() + 1) / 2; j ++)
				swap(s[j], s[s.size() - j - 1]);
	}
	cout << s;
}


#include <bits/stdc++.h>
using namespace std;
int cnt[500000], j = 1, m;
int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s;
	cin >> s >> m;
	for (int i = 0; i < m; i++){
		int a;
		cin >> a;
		cnt[a - 1]++;
	}
	for (int i = 0; i < (s.size() + 1)/2; i++){
		if (cnt[i] %2 == j)
			swap(s[i], s[s.size() - i - 1]);
		j = cnt[i] > 0 ? -j + 1 : j;
	}
	cout << s;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int q[100005],e[100005];

int main()
{
    string z,x,c;
    int a=0,s=0,g;
    cin>>z>>a;
    g=z.length();
    int w[a];
    for(int i=0;i<a;i++){
        cin>>s;
        q[s]++;
        w[i]=s;

    }
    for(int i=0;i<a;i++){
        if(q[w[i]]%2!=0){
                for(int d=w[i];d<=g/2;d++){
                    e[d]++;
                }
        }

    }
    for(int i=1;i<=g/2;i++){
        if(e[i]%2!=0){
            swap(z[i-1],z[g-i]);
        }
    }
    cout<<z;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int e[100005];
string z,x,c;
int a=0,s=0,g;
int main()
{
    cin>>z>>a;
    g=z.length();
    for(int i=0;i<a;i++){
        cin>>s;
        for(int d=s;d<=g/2;d++)
                    e[d]++;

    }

    for(int i=1;i<=g/2;i++){
        if(e[i]%2!=0){
            swap(z[i-1],z[g-i]);
        }
    }
    cout<<z;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int q[100005];
int main()
{
    string z,x,c;
    int a=0,s;
    cin>>z>>a;
    int w[a];
    for(int i=0;i<a;i++){
        cin>>s;
        q[s]++;
        w[i]=s;

    }
    for(int i=0;i<a;i++){
        if(q[w[i]]%2!=0){
           reverse(z.begin()+(w[i]-1),z.begin()+(z.length()-w[i]+1));
        }
    }
    cout<<z;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int q[100005],e[100005];

int main()
{
    vector<int> h;
    string z,x,c;
    int a=0,s=0,g;
    cin>>z>>a;
    g=z.length();
    int w[a+1];
    w[a]=-1;
    for(int i=0;i<a;i++){
        cin>>s;
        q[s]++;
        w[i]=s;

    }
    sort(w,w+a);
    for(int i=0;i<a;i++){
        if(q[w[i]]%2!=0&&w[i]!=w[i+1]){
             h.push_back(w[i]);
        }

    }
    h.push_back(g/2+1);
    for(int i=0;i<h.size()-1;i++){
        if(h[i]!=0){
            while(h[i]!=h[i+1]){
                swap(z[h[i]-1],z[g-h[i]]);
                h[i]=h[i]+1;
            }
            h[i+1]=0;
        }
            }
    cout<<z;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string z,x,c;
    int a=0,s;
    cin>>z>>a;
    for(int i=0;i<a;i++){
        cin>>s;
        reverse(z.begin()+(s-1),z.begin()+(z.length()-s+1));
    }
    cout<<z;
    return 0;
}


#include<bits\stdc++.h>
using namespace std;

int main() {
    int m;
    string s;
    cin >> s >> m;

    set<int> mm;

    for (int i = 0; i < m; i++) {
        int _mm;
        cin >> _mm;
        set<int>::iterator it = mm.find(_mm);
        if (it == mm.end())
            mm.insert(_mm);
        else mm.erase(it);
    }

    for (set<int>::iterator it = mm.begin(); it != mm.end(); it++)
        reverse(s.begin() + *it - 1, s.end() - *it + 1);

    cout << s;
}


#include<bits\stdc++.h>
using namespace std;

int main() {
    int m;
    string s;
    cin >> s >> m;
    set<int> mm;
    for (int i = 0; i < m; i++) {
        int _mm;
        cin >> _mm;
        set<int>::iterator it = mm.find(_mm);
        if (it != mm.end()) mm.erase(it);
        else mm.insert(_mm);
    }
    set<int>::iterator it = mm.begin();
    vector<pair<int, int>> br;
    for (; it != mm.end(); it++)
        br.push_back({ *it - 1, s.size() - *it + 1 });
    for (int i = 0; i < br.size(); i++) {
        if (!(i % 2) || i + 1 == br.size()) {
            if (i + 1 < br.size()) {
                for (int j = br[i].first, k = br[i].second - 1; j < br[i + 1].first; j++, k--)
                    swap(s[j], s[k]);
                i++;
            } else  reverse(s.begin() + br[i].first, s.begin() + br[i].second);
        }
    }
    cout << s;
}


#include<bits\stdc++.h>
using namespace std;

int main() {
    int m;
    string s;
    cin >> s >> m;
    set<int> mm;
    for (int i = 0; i < m; i++) {
        int _mm;
        cin >> _mm;
        set<int>::iterator it = mm.find(_mm);
        if (it != mm.end()) mm.erase(it);
        else mm.insert(_mm);
    }
    set<int>::iterator it = mm.begin();
    vector<pair<int, int>> br;
    for (; it != mm.end(); it++)
        br.push_back({ *it - 1, s.size() - *it + 1 });
    for (int i = 0; i < br.size(); i++) {
        if (!(i % 2) || i + 1 == br.size()) {
            if (i + 1 < br.size()) {
                for (int j = br[i].first, k = br[i + 1].second; j < br[i + 1].first; j++, k++)
                    swap(s[j], s[k]);
            }
            else {
                reverse(s.begin() + br[i].first, s.begin() + br[i].second);
            }
        }
    }
    cout << s;
}


#include<bits\stdc++.h>
using namespace std;
int main() {
    int m;
    string s;
    cin >> s >> m;
    for (int i = 0; i < m; i++) {
        int mm;
        cin >> mm;
        reverse(s.begin() + mm - 1, s.end() - mm +1);
    }
    cout << s;
}


#include<bits\stdc++.h>
using namespace std;

int main() {
    int m;
    string s;
    cin >> s >> m;
    set<int> mm;
    for (int i = 0; i < m; i++) {
        int _mm;
        cin >> _mm;
        set<int>::iterator it = mm.find(_mm);
        if (it != mm.end()) mm.erase(it);
        else mm.insert(_mm);
    }
    set<int>::iterator it = mm.begin();
    vector<pair<int, int>> br;
    for (; it != mm.end(); it++)
        br.push_back({ *it - 1, s.size() - *it + 1 });
    for (int i = 0; i < br.size();) {
        if (!(i % 2) || i + 1 == br.size()) {
            if (i + 1 < br.size()) {
                for (int j = br[i].first, k = br[i].second - 1; j < br[i + 1].first; j++, k--)
                    swap(s[j], s[k]);
                i += 2;
            } else  reverse(s.begin() + br[i].first, s.begin() + br[i].second), i++;
        } i++;
    }
    cout << s;
}


#include<bits\stdc++.h>
using namespace std;

int main() {
    int m;
    string s;
    cin >> s >> m;

    vector<int> mm;

    for (int i = 0; i < m; i++) {
        int _mm;
        cin >> _mm;
        vector<int>::iterator it = find(mm.begin(), mm.end(), _mm);
        if (it == mm.end())
            mm.push_back(_mm);
        else mm.erase(it);
    }

    for (int i = 0; i < mm.size(); i++)
        reverse(s.begin() + mm[i] - 1, s.end() - mm[i] + 1);

    cout << s;
}


#include<bits\stdc++.h>
using namespace std;

int main() {
    int m;
    string s;
    cin >> s >> m;
    set<int> mm;
    for (int i = 0; i < m; i++) {
        int _mm;
        cin >> _mm;
        set<int>::iterator it = mm.find(_mm);
        if (it != mm.end()) mm.erase(it);
        else mm.insert(_mm);
    }
    set<int>::iterator it = mm.begin();
    vector<pair<int, int>> br;
    for (; it != mm.end(); it++)
        br.push_back({ *it - 1, s.size() - *it + 1 });
    for (int i = 0; i < br.size(); i++) {
        if (!(i % 2)) {
            if (i + 1 < br.size()) {
                for (int j = br[i].first, k = br[i + 1].second; j < br[i + 1].first; j++, k++)
                    swap(s[j], s[k]);
            }
            else {
                reverse(s.begin() + br[i].first, s.begin() + br[i].second);
            }
        }
    }
    cout << s;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int m = 1000 * 100;

int k[m];

string in;

void reversed (int a, int c)
{
	int b = (a + c) / 2;

	for (int i = 0; i + a <= b; i++)
		swap (in[a + i], in[c - i]);
}

int main()
{
	int n;

	cin >> in >> n;

	for (int i = 0; i < n; i++)
	{
		int k[i];

		cin >> k[i];
	}

	for (int i = 0; i < n; i++)
	{
		if(k[i] == k[i + 1])
		{
			i++;
			continue;
		}

		reversed(k - 1, in.size() - k);
	}

	cout << in;

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int m = 1000 * 100 + 1;

int k[m];

string in;

void reversed (int a, int c)
{
	int b = (a + c) / 2;

	for (int i = 0; i + a <= b; ++i)
		swap (in[a + i], in[c - i]);
}

int main()
{
	int n;

	cin >> in >> n;

	for (int i = 0; i < n; ++i)
		cin >> k[i];

	int sz = in.size();
	n--;

	for (int i = 0; i <= n; i += 2)
	{
		if (k[i] > k[i + 1])
			swap(in[k[i + 1] - 1], in[sz - k[i + 1]]);
		if (k[i] < k[i + 1])
			swap(in[k[i] - 1], in[sz - k[i]]);
	}

	if (!(n & 1))
		reversed(k[n] - 1, sz - k[n]);

	cout << in;

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

string in;

void reversed (int a, int c)
{
	int b = (a + c) / 2;

	for (int i = 0; i + a <= b; i++)
		swap (in[a + i], in[c - i]);
}

int main()
{
	int n;

	cin >> in >> n;

	for (int i = 0; i < n; i++)
	{
		int k;

		cin >> k;

		reversed(k - 1, in.size() - k);
	}

	cout << in;

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int m = 1000 * 100 + 1;

int k[m];

string in;

void reversed (int a, int c)
{
	int b = (a + c) / 2;

	for (int i = 0; i + a <= b; i++)
		swap (in[a + i], in[c - i]);
}

int main()
{
	int n;

	cin >> in >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> k[i];
	}

	for (int i = 0; i < n; i++)
	{
		if(k[i] == k[i + 1])
		{
			i++;
			continue;
		}

		reversed(k[i] - 1, in.size() - k[i]);
	}

	cout << in;

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int m = 1000 * 100 + 1;

int k[m];

string in;

void reversed (int a, int c)
{
	int b = (a + c) / 2;

	for (int i = 0; i + a <= b; i++)
		swap (in[a + i], in[c - i]);
}

int main()
{
	int n;

	cin >> in >> n;

	for (int i = 0; i < n; i++)
		cin >> k[i];

	sort(k, k + n);

	int sz = in.size();
	n--;

	while (n > 0)
	{
		if (k[n] != k[n - 1])
			swap(in[k[n] - 1], in[sz - k[n]]);
		n -= 2;
	}

	if (n == 0)
		reversed(k[n] - 1, sz - k[n]);

	cout << in;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 100;

int arr[Maxn];

int main()
{
	string in;
	int n;

	cin >> in >> n;

	int tmp, sz= in.size();
	for (int i = 0; i < n; ++i)
	{
		cin >> tmp;
		--tmp;
		++arr[tmp];
	}

	for (int i = 1; i < in.size() / 2; ++i)
		arr[i] += arr[i - 1];
	for (int i = 0; i < in.size() / 2; ++i)
		if (arr[i] & 1)
			swap(in[i], in[sz - i - 1]);

	cout << in;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long  arr[10000];

int main()
{
    int n,t1,t2,k,a,b;
    string h;cin>>h;
    cin>>a;
    for(int g=0;g<a;g++){
cin>>b;
arr[b]++;
    }
    int ans=0;
    for(int g=0;g<=h.size()/2;g++){
      ans+=arr[g+1]  ;
      if(ans%2==1)  {
        swap(h[g],h[h.size()-(g+1)]);

      }
      //cout<<ans;
}
    cout<<h;

}


#include<bits/stdc++.h>
using namespace std;
long long  arr[10000];

int main()
{
    int n,t1,t2,k,a,b;
    string h;cin>>h;
    cin>>a;
    for(int g=0;g<a;g++){
cin>>b;
arr[b]++;
    }
    int ans=0;
    for(int g=0;g<h.size()/2;g++){
      ans+=arr[g+1]  ;
      if(ans%2==1)  {
        swap(h[g],h[h.size()-(g+1)]);

      }
      //cout<<ans;
}
    cout<<h;

}


#include<bits/stdc++.h>
using namespace std;
long long  arr[10000];

int main()
{
    int n,t1,t2,k,a,b;
    string h;cin>>h;
    cin>>a;
    for(int g=0;g<a;g++){
cin>>b;
arr[b]++;
    }
    int ans=0;
    for(int g=0;g<=h.size()/2;g++){
      ans+=arr[g+1]  ;
      if(ans%2==1)  {
        swap(h[g],h[h.size()-g-1]);

      }
      //cout<<ans;
}
    cout<<h;

}


#include<bits/stdc++.h>
using namespace std;
long long  arr[5000000];

int main()
{
    int n,t1,t2,k,a,b;
    string h;cin>>h;
    cin>>a;
    for(int g=0;g<a;g++){
cin>>b;
arr[b]++;
    }
    int ans=0;
    for(int g=0;g<h.size()/2;g++){
      ans+=arr[g+1]  ;
      if(ans%2==1)  {
        swap(h[g],h[h.size()-(g+1)]);

      }
      //cout<<ans;
}
    cout<<h;

}


#include <bits/stdc++.h>
using namespace std;
#define ret return 0;

vector <long long >d;
int GCD(int a, int b)
{
   if (b==0) return a;
   return GCD(b,a%b);
}
int main(){
    int n;
string g;cin>>g>>n;
int o;
for(int i=0;i<n;i++){
    cin>>o;
    reverse(g.begin()+o-1,g.end()-o+1);
}
cout<<g;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

int main()
{

    std::ios_base::sync_with_stdio (false);
    string s;

    cin>>s;
    int f=s.size();

    int a;
    scanf("%d",&a);
    int p;

    for(int i=0;i<a;i++){
        scanf("%d",&p);
        reverse(s.begin()+(p-1) ,s.end()-p+1 );
    }
    cout<<s;
return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

int main()
{

    std::ios_base::sync_with_stdio (true);
    string s;

    cin>>s;
    int f=s.size();

    int a;
    scanf("%d",&a);
    int p;

    for(int i=0;i<a;i++){
        scanf("%d",&p);
        reverse(s.begin()+(p-1) ,s.end()-p+1 );
    }
    cout<<s;
return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

int main()
{
    string s;

    cin>>s;
    int f=s.size();

    int a;
    cin>>a;
    int p;

    for(int i=0;i<a;i++){
        scanf("%d",&p);
        reverse(s.begin()+(p-1) ,s.end()-p+1 );
    }
    cout<<s;

return 0;
}


#include <iostream>
#include <string>
#include<string.h>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

char s[300000];
char re[300000];

int increase_array(int a[], int suru,int ses ){

    for(int i=suru;i<ses+1;i++){
        a[i]+=1;
    }
    return 0;

}

int value[300000]={};

int main()
{

    //std::ios_base::sync_with_stdio (true);

    gets(s);
    strcpy( re ,s);

    int f=strlen(s);

    int a;
    scanf("%d",&a);
    int p;

    for(int i=0;i<a;i++){
        scanf("%d",&p);

        int suru = p-1;
        int ses = f-p;
        increase_array(value , suru ,ses );
    }

    for(int i=0;i<f;i++){
        if (value[i] % 2 ==1){
            char temp= s[i];
            re[i] = s[ f-i-1 ];
            re[ f-i-1 ] =s[i];
        }
    }

    puts(re);

return 0;
}


#include <iostream>
#include <string>
#include<string.h>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

char s[300000];
char re[300000];

int increase_array(int a[], int suru,int ses ){

    for(int i=suru;i<ses+1;i++){
        a[i]+=1;
    }
    return 0;

}

int value[300000]={};

int main()
{

    //std::ios_base::sync_with_stdio (true);

    gets(s);

    int f=strlen(s);

    int a;
    scanf("%d",&a);
    int p;

    for(int i=0;i<a;i++){
        scanf("%d",&p);

        int suru = p-1;
        int ses = f-p;
        increase_array(value , suru ,ses );
    }

    for(int i=0;i<f;i++){
        if (value[i] % 2 ==1){
            char temp= s[i];
            re[i] = s[ f-i-1 ];
            re[ f-i-1 ] =s[i];
        }
        else{

            re[i] = s[i];
            re[f-i-1 ] = s[f-i-1 ];
        }

    }

    puts(re);

//    for(int i=0;i<a;i++){
//        scanf("%d",&p);
//        reverse(s.begin()+(p-1) ,s.end()-p+1 );
//    }
//    cout<<s;
return 0;
}


#include <iostream>
#include <string>
#include<string.h>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

char s[300000];
char re[300000];

int increase_array(int a[], int suru,int ses ){

    for(int i=suru;i<ses+1;i++){
        a[i]+=1;
    }
    return 0;

}

int value[300000]={};

int main()
{

    //std::ios_base::sync_with_stdio (true);

    gets(s);
    strcpy( re ,s);

    int f=strlen(s);

    int a;
    scanf("%d",&a);
    int p;

    for(int i=0;i<a;i++){
        scanf("%d",&p);

        int suru = p-1;
        int ses = f-p;
        value[suru] = value [suru] +1;
    }

        //for(int i=0;i<f;i++) cout<<value[i] <<" ";
    //cout<<endl;

    int cur=0;
    int recur=f-1;
    int trend=0;
    int loop=0;

    if(f%2==0){
        loop=f/2;
    }
    else{
        loop=f/2+1;
    }

    int save_kore=0;

    for(int i=0;i<loop;i++){

        cur=i;
        recur=f-i-1;

        if(value[i] ==0 ){
            value[cur] = trend;
            value [recur] = trend;
        }
        else{
            value[i]=value[i]+save_kore;
            //cout<<"value[i]   "<<value[i]<<endl;
            //cout<<"save   "<<save_kore<<endl;
            save_kore=value[i];
            if( value[i]%2==0 ){
                value[cur] = 0;
                value[recur] =0;
                trend=0;

            }
            else{
                value[cur] = 1;
                value[recur] =1;
                trend=1;
                //save_kore=value[i];
            }
        }
    }

//    for(int i=0;i<f;i++) cout<<value[i] <<" ";
//    cout<<endl;

    for(int i=0;i<f;i++){
        if (value[i] % 2 ==1){
            char temp= s[i];
            re[i] = s[ f-i-1 ];
            re[ f-i-1 ] =s[i];
        }
    }

    puts(re);

return 0;
}


#include <cstring>
#include <cstdio>
using namespace std;
char str[200100];
int cum[200100];
int main()
{
    int day,a,sz;
    scanf("%s %d",str,&day);
    sz=strlen(str);
    while(day--){
        scanf("%d",&a);
        cum[a-1]++;
    }
    for(int i=0; i<sz/2; i++){
        cum[i]+=cum[i-1];
 		if(cum[i]%2==0)cum[i]=0;
		else cum[i]=1;
    }
    for(int i=0; i<=sz/2; i++){
        if(cum[i]%2){
            char tmp=str[sz-i-1];
            str[sz-i-1]=str[i];
            str[i]=tmp;
        }
    }
    printf("%s\n", str);
}


#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int day, a=0, e=0, sz=str.length();
    cin>>day;
    int cum[day]={0};
    for(int i=0; i<sz; i++)cum[i]=0;
    for(int i=0; i<day; i++){
        cin>>a;
        e=(sz-a)+1;
        for(int i=0; i<=sz; i++){
            if(i>=a-1 && i<=e-1)cum[i]++;
        }
        for(int i=0; i<sz; i++){
            if(cum[i]%2==0)cum[i]=0;
            if(cum[i]%2==1)cum[i]=1;
        }
    }
    for(int i=0; i<sz; i++){
        if(cum[i]==1){
            swap(str[i], str[(sz)-(i+1)]);
            cum[(sz)-(i+1)]=0;
        }
    }
    cout<<str<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int day, a=0, e=0, sz=str.length(), min_a=2000000,max_e=0;
    cin>>day;
    int cum[sz]={0};
    while(day--){
        cin>>a;
        e=(sz-a)+1;
        if((e-1)>max_e)max_e=e-1;
        if((a-1)<min_a)min_a=a-1;
        for(int i=a-1; i<=e-1; i++){
            cum[i]++;
            if(cum[i]%2==0)cum[i]=0;
            if(cum[i]%2==1)cum[i]=1;
        }
    }
    for(int i=min_a; i<=max_e; i++){
        if(cum[i]==1){
            swap(str[i], str[(sz)-(i+1)]);
            cum[(sz)-(i+1)]=0;
        }
    }
    cout<<str<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int day, a=0, e=0, sz=str.length();
    cin>>day;
    int cum[sz]={0};
    for(int i=0; i<sz; i++)cum[i]=0;
    while(day--){
        cin>>a;
        e=(sz-a)+1;
        for(int i=a-1; i<=e-1; i++){
            cum[i]++;
            if(cum[i]%2==0)cum[i]=0;
            if(cum[i]%2==1)cum[i]=1;
        }
    }
    for(int i=0; i<sz; i++){
        if(cum[i]==1){
            swap(str[i], str[(sz)-(i+1)]);
            cum[(sz)-(i+1)]=0;
        }
    }
    cout<<str<<endl;
    return 0;
}


#include <cstring>
#include <cstdio>
using namespace std;
char str[200100];
int cum[200100];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int day,a,sz;
    scanf("%s %d",str,&day);
    sz=strlen(str);
    while(day--){
        scanf("%d",&a);
        cum[a-1]++;
    }
    for(int i=0; i<sz/2; i++){
        cum[i]+=cum[i-1];
 		if(cum[i]%2==0)cum[i]=0;
		else cum[i]=1;
    }
    for(int i=0; i<=sz/2; i++){
        if(cum[i]%2){
            char tmp=str[sz-i-1];
            str[sz-i-1]=str[i];
            str[i]=tmp;
        }
    }
    printf("%s\n", str);
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int day, a=0, e=0, sz=str.length(), min_a=2000000;
    cin>>day;
    int cum[sz]={0};
    while(day--){
        cin>>a;
        e=(sz-a)+1;
        if((a-1)<min_a)min_a=a-1;
        for(int i=a-1; i<=e-1; i++){
            cum[i]++;
            if(cum[i]%2==0)cum[i]=0;
            if(cum[i]%2==1)cum[i]=1;
        }
    }
    for(int i=min_a; i<=sz/2; i++){
        if(cum[i]==1){
            swap(str[i], str[(sz)-(i+1)]);
            cum[(sz)-(i+1)]=0;
        }
    }
    cout<<str<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int day, a=0, e=0, sz=str.length();
    cin>>day;
    int cum[day];
    for(int i=0; i<sz; i++)cum[i]=0;
    while(day--){
        cin>>a;
        e=(sz-a)+1;
        for(int i=a-1; i<=e-1; i++)cum[i]++;
    }
    for(int i=0; i<sz; i++){
        if(cum[i]%2==0)cum[i]=0;
        if(cum[i]%2==1)cum[i]=1;
    }
    for(int i=0; i<sz; i++){
        if(cum[i]==1){
            swap(str[i], str[sz-(i+1)]);
            cum[sz-(i+1)]=0;
        }
    }
    cout<<str<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
#include <stack>
using namespace std;

#define lp(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sz(v) (int)v.size()
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define uq(c) (c).resize(unique(all(c)) - (c).begin())
typedef long long ll;
int n, e;
vector< vector<int> > adj;
vector<bool> visited;

vector<int> topsort;
vector<int> start, finish;
bool anyCycle = 0;
int timer = 0;
void dance()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}

void dfs(int node)
{
	visited[node] = true;

	rep(i, adj[node])
	{
		int child = adj[node][i];
		if (!visited[child])
			dfs(child);
	}

	topsort.push_back(node);
}

int ConnectedComponenetsCnt()
{
	int cnt = 0;
	lp(i, n)
	{
		if (!visited[i])
		{
			dfs(i);
			cnt++;
		}
	}
	return cnt;
}

int const N = 2000 + 4;
int const MMM = 10e5;
char a[N][N];
int b[N][N];
char g[N][N];
int arr[MMM];
ll c = 0;
vector<char>vv;
void back(ll n)
{
	if (n > c)return;
	vv.push_back(n);
	back(n * 10 + 4);
	back(n * 10 + 7);

}
void printVec(vector<char> v2, string s = "")
{
	cout << s;
	for (int i = 0; i < (int)v2.size(); ++i)
		cout << v2[i] << " ";
	cout << "\n";
}
// 4 7    44 47 74 77     444 447 474 477 744 747 774 777
int main()
{
	dance();
	string s; cin >> s;
	ll n, arr[200000];
	cin >> n;
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	ll i = 0;

	while (n--)
	{
		ll l = arr[i];
		ll r = s.size() - l + 1;
		reverse(s.begin() + l-1, s.begin() + r);
		i++;
	}
	cout << s;

	return 0;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
#include <stack>
using namespace std;

#define lp(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sz(v) (int)v.size()
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define uq(c) (c).resize(unique(all(c)) - (c).begin())
typedef long long ll;
int n, e;
vector< vector<int> > adj;
vector<bool> visited;

vector<int> topsort;
vector<int> start, finish;
bool anyCycle = 0;
int timer = 0;
void dance()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}

void dfs(int node)
{
	visited[node] = true;

	rep(i, adj[node])
	{
		int child = adj[node][i];
		if (!visited[child])
			dfs(child);
	}

	topsort.push_back(node);
}

int ConnectedComponenetsCnt()
{
	int cnt = 0;
	lp(i, n)
	{
		if (!visited[i])
		{
			dfs(i);
			cnt++;
		}
	}
	return cnt;
}

int const N = 2000 + 4;
int const MMM = 10e5;
char a[N][N];
int b[N][N];
char g[N][N];
int arr[MMM];
ll c = 0;
vector<char>vv;
void back(ll n)
{
	if (n > c)return;
	vv.push_back(n);
	back(n * 10 + 4);
	back(n * 10 + 7);

}
void printVec(vector<char> v2, string s = "")
{
	cout << s;
	for (int i = 0; i < (int)v2.size(); ++i)
		cout << v2[i] << " ";
	cout << "\n";
}
// 4 7    44 47 74 77     444 447 474 477 744 747 774 777
int main()
{
	dance();
	string s; cin >> s;
	ll n;
	cin >> n;

	ll i = 0;

	while (n--)
	{
		cin >> i;
		ll l = i;
		ll r = s.size() - l + 1;
		reverse(s.begin() + l-1, s.begin() + r);

	}
	cout << s;

	return 0;

}


#include <bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
#include <stack>
using namespace std;
#define lp(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sz(v) (int)v.size()
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define uq(c) (c).resize(unique(all(c)) - (c).begin())
typedef long long ll;

int main()
{
       string s;int m,n,d;
       cin>>s>>n;
       int frq[500000]={0};

       for(int i=0;i<n;i++)
       {
           cin>>d;
           frq[d]++;

       }
       int ans=0;
        for(int i=1;i<=s.size()/2;i++)
        {
            ans+=frq[i];
            if(ans%2)
                swap(s[i-1],s[s.size()-i]);
        }
        cout<<s;
	return 0;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
#include <stack>
using namespace std;

#define lp(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sz(v) (int)v.size()
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define uq(c) (c).resize(unique(all(c)) - (c).begin())
typedef long long ll;
int n, e;
vector< vector<int> > adj;
vector<bool> visited;

vector<int> topsort;
vector<int> start, finish;
bool anyCycle = 0;
int timer = 0;
void dance()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}

void dfs(int node)
{
	visited[node] = true;

	rep(i, adj[node])
	{
		int child = adj[node][i];
		if (!visited[child])
			dfs(child);
	}

	topsort.push_back(node);
}

int ConnectedComponenetsCnt()
{
	int cnt = 0;
	lp(i, n)
	{
		if (!visited[i])
		{
			dfs(i);
			cnt++;
		}
	}
	return cnt;
}

int const N = 2000 + 4;
int const MMM = 10e5;
char a[N][N];
int b[N][N];
char g[N][N];
int arr[MMM];
ll c = 0;
vector<char>vv;
void back(ll n)
{
	if (n > c)return;
	vv.push_back(n);
	back(n * 10 + 4);
	back(n * 10 + 7);

}
void printVec(vector<char> v2, string s = "")
{
	cout << s;
	for (int i = 0; i < (int)v2.size(); ++i)
		cout << v2[i] << " ";
	cout << "\n";
}
// 4 7    44 47 74 77     444 447 474 477 744 747 774 777
int main()
{
	dance();
	string s; cin >> s;
	int n, arr[200000];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int i = 0;

	while (n--)
	{
		int l = arr[i];
		int r = s.size() - l + 1;
		reverse(s.begin() + l-1, s.begin() + r);
		i++;
	}
	cout << s;

	return 0;

}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5+1, SIZ = 1e5+1;
char a[SIZE];
int c[SIZ];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    string b = a;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        c[x]++;
    }
    int z = 0;
    for(int i = 1; i < b.size()-1;i++){
            z+=c[i];
            if(z%2==1){
                cout << i << " " << b.size()-i-1 << " " << b << " " << c[i] << endl;
                swap(b[i-1],b[b.size()-i]);
            }
    }
    for(int i = 0 ; i <b.size();i++)a[i]=b[i];
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5+1;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a+x-1,a+strlen(a)-x+1);
    }
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5+1, SIZ = 1e5+1;
char a[SIZE];
int c[SIZ];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    string b = a;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        c[x]++;
    }
    for(int i = 0; i < SIZ;i++)if(c[i]%2){
        reverse(b.begin()+i-1,b.end()-i+1);
    }
    for(int i = 0 ; i <b.size();i++)a[i]=b[i];
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int SIZE = 2e5;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    string b = a;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(b.begin()+x-1,b.end()-x+1);
    }
    cout << b;
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5+1, SIZ = 1e5+1;
char a[SIZE];
int c[SIZ];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    string b = a;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        c[x]++;
    }
    int z = 0;
    for(int i = 1; i < b.size()-1;i++){
            z+=c[i];
            if(z%2==1){
                swap(b[i-1],b[b.size()-i]);
            }
    }
    for(int i = 0 ; i <b.size();i++)a[i]=b[i];
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string a;
    cin >> a;
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a.begin()+x,a.end()-x+1);
    }
    cout << a;
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a+x-1,a+strlen(a)-i);
    }
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a+x-1,a+strlen(a)-x+1);
    }
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5+1, SIZ = 1e5+1;
char a[SIZE];
int c[SIZ];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    string b = a;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        c[x]++;
    }
    int z = 0;
    for(int i = 0; i < b.size()-1;i++){
            z+=c[i];
            if(z%2==1){
                swap(b[i-1],b[b.size()-i]);
            }
    }
    for(int i = 0 ; i <b.size();i++)a[i]=b[i];
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a+x-1,a+strlen(a)-i-1);
    }
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int SIZE = 2e5;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    string b = a;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(b.begin()+x-1,b.end()-x+1);
    }
    for(int i = 0 ; i <b.size();i++)a[i]=b[i];
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5+1, SIZ = 1e5+1;
char a[SIZE];
int c[SIZ];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    string b = a;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        c[x]++;
    }
    int z = 0;
    for(int i = 1; i <= b.size()/2;i++){
            z+=c[i];
            if(z%2==1){
                swap(b[i-1],b[b.size()-i]);
            }
    }
    for(int i = 0 ; i <b.size();i++)a[i]=b[i];
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZE = 2e5;
char a[SIZE];

int main()
{
    scanf("%s",&a);
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a+x-1,a+strlen(a)-i+1);
    }
    printf("%s",a);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string a;
    cin >> a;
    int m;
    cin >> m;
    for(int i = 0 ; i < m; i++){
        int x;
        scanf("%d",&x);
        reverse(a.begin()+x-1,a.end()-x+1);
    }
    cout << a;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    int m,n;
    char s[200001];
    cin>>s;
    cin>>m;
    n=LEN(s);

    bool v[n/2];
    MS0(v);
    FOR(i,m) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,n/2) {
        f^=v[i];
        if(f) SWAP(s[i],s[n-i-1]);
    }
    cout<<s;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    int m,n;
    char s[200001];
    cin>>s;
    cin>>m;
    n=LEN(s);

    bool v[n/2];
    MS0(v);
    FOR(i,m) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,n/2) {
        f^=v[i];
        if(f) {
            SWAP(s[i],s[n-i-1]);
        }
    }
    cout<<s;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    char s[200001];
    cin>>s;
    int m,n;
    n=LEN(s)/2;
    cin>>m;
    bool v[n/2];
    MS0(v);
    FOR(i,m) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,n/2) {
        f^=v[i];
        if(f) {
            char t=s[i];
            s[i]=s[n-i-1];
            s[n-i-1]=t;
        }
    }
    cout<<s;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    char s[200001];
    cin>>s;
    int n;
    cin>>n;
    bool v[LEN(s)/2];
    MS0(v);
    FOR(i,n) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,LEN(s)/2) {
        f^=v[i];
        if(f) {
            char t=s[i];
            s[i]=s[LEN(s)-i-1];
            s[LEN(s)-i-1]=t;
        }
    }
    cout<<s;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    int m,n;
    char s[200001];
    cin>>s;
    cin>>m;
    n=LEN(s);

    bool v[n/2];
    MS0(v);
    FOR(i,m) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,n/2) {
        f^=v[i];
        if(f) {
            char t=s[i];
            s[i]=s[n-i-1];
            s[n-i-1]=t;
        }
    }
    cout<<s;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    char s[200001];
    cin>>s;
    int m,n;
    cin>>m;
    n=LEN(s)/2;
    bool v[n];
    MS0(v);
    FOR(i,m) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,n) {
        f^=v[i];
        if(f) {
            char t=s[i];
            s[i]=s[n-i-1];
            s[n-i-1]=t;
        }
    }
    cout<<s;
    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>
#define FOR(I,N) for(int I=0;I<N;++I)
#define FORR(I,N) for(int I=N-1;I>=0;--I)
#define FORAB(I,A,B) for(int I=(A);I<(B);++I)
#define FORRAB(I,A,B) for(int I=(B)-1;I>=(A);--I)
#define LEN(X) strlen(X)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MS0(X) memset((X),0,sizeof((X)))
#define SIZE(A) (sizeof((A))/sizeof((A[0])))
#define SORT(A) sort((A),(A)+SIZE((A)))
#define SORTR(A) sort((A),(A)+SIZE((A)),greater<int>())
#define SWAP(A,B) A^=B^=A^=B

typedef long long LL;

using namespace std;

// -----------------------------------------------------------------------------
// END TEMPLATE
// -----------------------------------------------------------------------------

int main() {
    char s[200001];
    cin>>s;
    int n;
    cin>>n;
    bool v[LEN(s)/2];
    MS0(v);
    FOR(i,n) {
        int p;
        cin>>p;
        v[p-1]^=1;
    }

    bool f=0;
    FOR(i,LEN(s)/2) {
        f^=v[i];
        if(f) SWAP(s[i],s[LEN(s)-i-1]);
    }
    cout<<s;
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
//            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i+1]+1);
            reverse(s+l-b[i+1]-1,s+l-b[i]);
        }
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i+1]+1);
            reverse(s+l-b[i+1]-1,s+l-b[i]);
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
//            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i+1]+1);
            reverse(s+l-b[i+1]-1,s+l-b[i]);
        }
        chk2(b[i],l);
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i+1]+1);
            reverse(s+l-b[i+1]-1,s+l-b[i]);
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i]+1);
            reverse(s+l-b[i],s+l-b[i]-1);
        }
        chk2(b[i],l);
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i]+1);
            reverse(s+l-b[i],s+l-b[i]-1);
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];
char p[200001];

int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
        }
    }
    sort(b,b+k);
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i+1]);
            reverse(s+l-b[i+1],s+l-b[i]);
            k=0;
            for(int j=b[i]; j<b[i+1]; j++) {
                p[k++] = s[j];
            }
            int q = b[i];
            for(int j=l-b[i+1]; j<=l-b[i]-1; j++) {
                s[q++] = s[j];
            }
            k=0;
            for(int j=l-b[i+1]; j<=l-b[i]-1; j++) {
                s[j] = p[k++];
            }
        }
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i+1]);
            reverse(s+l-b[i+1],s+l-b[i]);
            k=0;
            for(int j=b[i]; j<b[i+1]; j++) {
                p[k++] = s[j];
            }
            int q = b[i];
            for(int j=l-b[i+1]; j<=l-b[i]-1; j++) {
                s[q++] = s[j];
            }
            k=0;
            for(int j=l-b[i+1]; j<=l-b[i]-1; j++) {
                s[j] = p[k++];
            }
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
//            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i]+1);
            reverse(s+l-b[i]-2,s+l-b[i]-1);
        }
//        chk2(b[i],l);
        reverse(s+b[i],s+l-b[i]-1);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i]+1);
            reverse(s+l-b[i]-2,s+l-b[i]-1);
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
//            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i]+2);
            reverse(s+l-b[i]-2,s+l-b[i]);
        }
        chk2(b[i],l);
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i]+2);
            reverse(s+l-b[i]-2,s+l-b[i]);
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
//            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i]+1);
            reverse(s+l-b[i],s+l-b[i]-1);
        }
//        chk2(b[i],l);
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i]+1);
            reverse(s+l-b[i],s+l-b[i]-1);
        }
    }
    printf("%s", s);
    return 0;
}


//Akhilesh Gulati, NSIT
//reference taken from https://comeoncodeon.wordpress.com/category/algorithm/
#include<bits/stdc++.h>
void printmat(int rs, int re, int cs, int ce, int ncol, int* a) {
    printf("   ");
    for(int j=cs; j<=ce; j++) {
        printf("%3d", j);
    }
    printf("\n");
    for(int i=rs; i<=re; i++) {
        printf("%3d", i);
        for(int j=cs; j<=ce; j++) {
            printf("%3d", a[i*ncol+j]);
        }
        printf("\n");
    }
}
#define ll long long int
#define gc getchar
void scan(int &x) { register int c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
void scanll(ll &x) { register ll c = gc(); x = 0; for(;(c<48 || c>57);c = gc()); for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;} }
#define pii pair<int,int>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define foreach(it, t) for(auto it = t.begin(); it!=t.end(); it++)  //it: pointer
#define vi vector<int>
#define pb push_back
#define in(n) scan(n)
#define inll(n) scanll(n)
#define out(n) printf("%d", n)
#define outll(n) printf("%lld", n)
#define outs(n) printf("%d ",n)   //with space
#define outsll(n) printf("%lld ",n)   //with space
#define newl printf("\n")
#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl

using namespace std;

char s[200001];
int a[200001];
int b[200001];

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    #endif
    scanf("%s", s);
    int i,l=strlen(s),m;
    in(m);
    int t,k=0;
    for(i=0; i<m; i++) {
        in(t);
        t--;
        a[t] ^= 1;
    }
    for(i=0; i<200001; i++) {
        if(a[i]) {
            b[k++] = i;
//            chk(i);
        }
    }
    int n=k;
    if(n%2) {
        for(i=0; i<n-2; i+=2) {
            reverse(s+b[i],s+b[i]+2);
            reverse(s+l-b[i]-1,s+l-b[i]);
        }
        reverse(s+b[i],s+l-b[i]);
    }
    else {
        for(i=0; i<n-1; i+=2) {
            reverse(s+b[i],s+b[i]+2);
            reverse(s+l-b[i]-1,s+l-b[i]);
        }
    }
    printf("%s", s);
    return 0;
}


#include <bits/stdc++.h>

const int M=1e5+7;
const long long N=1e12+7;

using namespace std;
int pre[M], n, a;
string s;
int main()
{
    cin >> s >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		++pre[a - 1];
	}
	for (long long i = 0; i < s.size() / 2; ++i) {
		if (i)pre[i] += pre[i - 1];
		if (pre[i] & 1) swap(s[i], s[s.size() - i - 1]);
	}
	cout << s << '\n';
	return 0;
    return 0;
}


#include <bits/stdc++.h>

const int M=1e5+7;
const long long N=1e12+7;

using namespace std;
void rev(int i,int j,string &str){
    --i;
    --j;
    while(i<j){
        swap(str[i],str[j]);
        ++i;
        --j;
    }
}
string str;
int m,x,fr[M];
int main()
{
    cin>>str;
    scanf("%d",&m);
    for(int i=0;i<m;++i){
        scanf("%d",&x);
        ++fr[x];
    }
    int sz=str.size();
    for(int i=1;i<=sz;++i){
        if(fr[i]&1)rev(i,sz-i+1,str);
    }
    cout<<str;
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
const int N = 100000;
int pre[N], n, a;
string s;
int main() {
	cin >> s >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		++pre[a - 1];
	}
	for (long long i = 0; i < s.size() / 2; ++i) {
		if (i)pre[i] += pre[i - 1];
		if (pre[i] & 1) swap(s[i], s[s.size() - i - 1]);
	}
	cout << s << '\n';
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
const int N = 100000;
int pre[N],n,a;
string s;
int main() {
	cin >> s >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		++pre[a-1];
	}
	for(int i=1;i<s.size();++i)
		pre[i] += pre[i - 1];
	for (int i = 0; i<s.size() / 2; ++i)
		if (pre[i] & 1) swap(s[i], s[s.size() - i - 1]);
	cout << s << '\n';
	return 0;
}


#include <bits/stdc++.h>

const int M=1e5+7;
const long long N=1e12+7;

using namespace std;
string str;
int m,x,fr[M];
int main()
{
    cin>>str;
    scanf("%d",&m);
    for(int i=0;i<m;++i){
        scanf("%d",&x);
        ++fr[x];
    }
    int sz=str.size();
    for(int i=1;i<=sz;++i)
        if(fr[i]&1)swap(str[i-1],str[sz-i]);
    cout<<str;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <complex>
using namespace std;
int num[100010];
char str[2*100010];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{

    while(cin>>str){
        memset(num,0,sizeof(num));
        int n=strlen(str);
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            int a;
            scanf("%d",&a);
            num[a-1]++;
        }
        for(int i=1 ;i<n;i++){
                num[i] += num[i-1];
        }
        for(int i=0;i<n/2;i++){
            if(num[i]%2){
                swap(str[i],str[n-i-1]);
            }
        }
        puts(str);
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <complex>
using namespace std;
int main()
{
    string str;
    while(cin>>str){
        int n=str.length();
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            int a;
            scanf("%d",&a);
            reverse(str.begin()+a-1,str.begin()+(n-a+1));
        }
        cout<<str<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <complex>
using namespace std;
int num[100010];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    string str;
    while(cin>>str){
        int n=str.length();
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            scanf("%d",&num[i]);

        }
        sort(num,num+m,cmp);
        for(int i=0;i<m;i++){
            reverse(str.begin()+num[i]-1,str.begin()+(n-num[i]+1));
        }
        cout<<str<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <complex>
using namespace std;
int num[2*100010];
char str[2*100010];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{

    while(cin>>str){
        memset(num,0,sizeof(num));
        int n=strlen(str);
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            int a;
            scanf("%d",&a);
            num[a-1]++;
        }
        for(int i=1 ;i<n;i++){
                num[i] += num[i-1];
        }
        for(int i=0;i<n/2;i++){
            if(num[i]%2){
                swap(str[i],str[n-i-1]);
            }
        }
        puts(str);
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <complex>
using namespace std;
int num[100010];
char str[2*100010];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{

    while(gets(str)){

        int n=strlen(str);
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            int a;
            scanf("%d",&a);
            num[a]++;
        }
        for(int i=1;i<n/2;i++){
            num[i]+=num[i-1];
            if(num[i]%2){
                swap(str[i-1],str[n-i]);
            }
        }
        puts(str);
        getchar();
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <complex>
using namespace std;
int num[100010];
char str[2*100010];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{

    while(gets(str)){
        int n=strlen(str);
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            scanf("%d",&num[i]);
        }
        sort(num,num+m,cmp);
        for(int i=0;i<m;i++){
            reverse(str+num[i]-1,str+(n-num[i]+1));
        }
        puts(str);
        getchar();
    }
    return 0;
}


#include <iostream>

using namespace std;

// always declare big array here it's safer for stack than inside of main

int main(){

         // cin.sync_with_stdio(0); to speed input but scanf and printf faster
         // cin.tie(0);             not use scanf after that and not use endl but \n

         // elements before me is (i - 1) * m + m - 1

		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
		 cout.tie(NULL);

		//  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);

        string s;
        cin >> s;

        int m , x;
        cin >> m;

        for(int i = 0 ; i < m ; i++){
            cin >> x;
            string s1;

            for(int i = 0 ; i < x - 1 ; i++)
                s1 += s[i];

            int j = s.size() - x;

            for(int i = j ; i >= x - 1 ; i--)
                s1 += s[i];

            for(int i = j + 1 ; i < s.size() ; i++)
                s1 += s[i];
            s = s1;
        }

        cout << s;

 return 0;
}


#include <iostream>

using namespace std;

// always declare big array here it's safer for stack than inside of main

int arr[2000005];

int main(){

         // cin.sync_with_stdio(0); to speed input but scanf and printf faster
         // cin.tie(0);             not use scanf after that and not use endl but \n

         // elements before me is (i - 1) * m + m - 1

		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
		 cout.tie(NULL);

		//  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);

        string s;
        cin >> s;

        int m , x;
        cin >> m;

        while(m--){
            cin >> x;
            arr[--x]++;
        }

        int l = s.size();
        for(int i = 0 ; i < l / 2 ; i++){
            if(i != 0)
                arr[i] += arr[i - 1];
            if(arr[i] & 1)
                swap(s[i] , s[l - i - 1]);
        }

        cout << s;

 return 0;
}


#include <iostream>

using namespace std;

// always declare big array here it's safer for stack than inside of main

int arr[2000005]{0};

int main(){

         // cin.sync_with_stdio(0); to speed input but scanf and printf faster
         // cin.tie(0);             not use scanf after that and not use endl but \n

         // elements before me is (i - 1) * m + m - 1

		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
		 cout.tie(NULL);

		//  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);

        string s;
        cin >> s;

        int m , x;
        cin >> m;

        while(m--){
            cin >> x;
            arr[--x]++;
        }

        int l = s.size();
        for(int i = 0 ; i < l / 2 ; i++){
            if(i != 0)
                arr[i] += arr[i - 1];
            if(arr[i] & 1)
                swap(s[i] , s[l - i - 1]);
        }

        cout << s;

 return 0;
}


#include <iostream>

using namespace std;

// always declare big array here it's safer for stack than inside of main

int main(){

         // cin.sync_with_stdio(0); to speed input but scanf and printf faster
         // cin.tie(0);             not use scanf after that and not use endl but \n

         // elements before me is (i - 1) * m + m - 1

		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
		 cout.tie(NULL);

		//  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);

        string s;
        cin >> s;

        int m , position;
        cin >> m;

        for(int i = 0 ; i < m ; i++){
            cin >> position;
            position--;
            int j = s.size() - 1 - position;
            for(int i = position ; i <= j ; i++){
                    swap(s[i] , s[j]);
                    j--;
            }
        }

        cout << s;

 return 0;
}


#include <iostream>

using namespace std;

// always declare big array here it's safer for stack than inside of main

int arr[200005];

int main(){

         // cin.sync_with_stdio(0); to speed input but scanf and printf faster
         // cin.tie(0);             not use scanf after that and not use endl but \n

         // elements before me is (i - 1) * m + m - 1

		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
		 cout.tie(NULL);

		//  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);

        // the explanation down there after code

        string s;
        cin >> s;

        int m , x;
        cin >> m;

        while(m--){
            cin >> x;
            arr[--x]++;
        }

        int l = s.size();
        for(int i = 0 ; i < l / 2 ; i++){
            if(i != 0)
                arr[i] += arr[i - 1];
            if(arr[i] & 1)
                swap(s[i] , s[l - i - 1]);
        }

        cout << s;

 return 0;
}


# include <stdio.h>
# include <string.h>
int main()
{
	char ch[100005];
	long long int n,m,dp[100005],i,l,r;
	scanf("%s",ch);

	n=strlen(ch);
	/*if(ch[0]==ch[1])
		dp[0]=1;
	for(i=1;i<n-1;i++)
	{
		if(ch[i]==ch[i+1])
			dp[i]=dp[i-1]+1;
		else
			dp[i]=dp[i-1];
	}
	dp[n-1]=dp[n-2]+1;*/
	//for(i=0;i<n;i++)
	//	printf("%lld ",dp[i]);
	scanf("%lld",&m);
	while(m--)
	{
		scanf("%lld %lld",&l,&r);
		long long int c=0;
		l=l-1;
		r=r-1;
	//	printf("%lld\n",dp[r-1]-dp[l-1]);
		for(i=l;i<r;i++)
			if(ch[i]==ch[i+1])
				c++;
		printf("%lld\n",c);
	}
	return 0;
}


# include <stdio.h>
# include <string.h>
int main()
{
	char ch[100005];
	long long int n,m,dp[100005],i,l,r;
	scanf("%s",ch);

	n=strlen(ch);
	if(ch[0]==ch[1])
		dp[1]=1;
	for(i=1;i<n-1;i++)
	{
		if(ch[i]==ch[i+1])
			dp[i+1]=dp[i]+1;
		else
			dp[i+1]=dp[i];
	}
	dp[n]=dp[n]+1;
//	for(i=0;i<n;i++)
//		printf("%lld ",dp[i]);
	scanf("%lld",&m);
	while(m--)
	{
		scanf("%lld %lld",&l,&r);
		l=l-1;
		r=r-1;
		printf("%lld\n",dp[r]-dp[l]);
	}
	return 0;
}


# include <stdio.h>
# include <string.h>
int main()
{
	char ch[100005];
	long long int n,m,dp[100005],i,l,r;
	scanf("%s",ch);

	n=strlen(ch);
	if(ch[0]==ch[1])
		dp[0]=1;
	for(i=1;i<n-1;i++)
	{
		if(ch[i]==ch[i+1])
			dp[i]=dp[i-1]+1;
		else
			dp[i]=dp[i-1];
	}
	dp[n-1]=dp[n-2]+1;
//	for(i=0;i<n;i++)
//		printf("%lld ",dp[i]);
	scanf("%lld",&m);
	while(m--)
	{
		scanf("%lld %lld",&l,&r);
		l=l-1;
		r=r-1;
		printf("%lld\n",dp[r-1]-dp[l-1]);
	}
	return 0;
}


#include<stdio.h>

int main() {

    char a[100010];
    scanf("%s",a);
    int dp[100010], i;
    int n=strlen(a);
    dp[1]=0;

    for(i=1;i<n;i++) 	{
        if(a[i]==a[i-1])dp[i+1]=1+dp[i];
        else	dp[i+1]=dp[i];
     }
 	 int m;
    scanf("%d",&m);
   while(m--) 	{
         int x,y;
        scanf("%d%d",&x,&y);
       	printf("%d\n",dp[y]-dp[x]);
	}
	return 0;
}


#inlude<stdio.h>

int main() {

    char a[100010];
    scanf("%s",a);
    int dp[100010], i;
    int n=strlen(a);
    dp[1]=0;

    for(i=1;i<n;i++) 	{
        if(a[i]==a[i-1])dp[i+1]=1+dp[i];
        else	dp[i+1]=dp[i];
     }
 	 int m;
    scanf("%d",&m);
   while(m--) 	{
         int x,y;
        scanf("%d%d",&x,&y);
       	printf("%d\n",dp[y]-dp[x]);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main ()
{
    int b[100000],c,n,x,y,z,count=0,i,j,k=0,l,numbering=0;
    char a[100000];
    gets(a);
    l=strlen(a);
    for(i=0;i<l-1;i++)
    {
        if(a[i]!=a[i+1])
        {
            numbering++;
            b[i+1]=numbering;
        }
        else
        {
            b[i+1]=numbering;
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&x,&y);
        c=y-x-(b[y-1]-b[x-1]);
        a[i]=c;
    }
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main ()
{
    int b[100000],d[100000],c,n,x,y,z,count=0,i,j,k=0,l,numbering=0;
    char a[100000];
    gets(a);
    l=strlen(a);
    for(i=0;i<l-1;i++)
    {
        if(a[i]!=a[i+1])
        {
            numbering++;
            b[i+1]=numbering;
        }
        else
        {
            b[i+1]=numbering;
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&x,&y);
        c=y-x-(b[y-1]-b[x-1]);
        d[i]=c;
    }
    for(i=0;i<n;i++)
    {
        printf("%d\n",d[i]);
    }
    return 0;
}


#include<stdio.h>
int main ()
{
    int b[100000],n,x,y,count=0,i,j,k=0;
    char a[100000];
    gets(a);
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&x,&y);
        for(j=x-1;j<y-1;j++)
        {
            if(a[j]==a[j+1])count++;
            else break;
        }
        b[k]=count;
        k++;
        count=0;
    }
    for(i=0;i<n;i++)
    {
        printf("%d\n",b[i]);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int m, i, a, b, len_charr;
	int *arr;
	char *charr;

	charr = malloc(100001*sizeof(char));
	scanf("%s", charr);
	len_charr = strlen(charr);

	scanf("%d", &m);
	arr = malloc(len_charr*sizeof(int)));
	arr[0] = 0;
	for(i=1; i<len_charr; ++i) {
		arr[i] = arr[i-1];
		if(charr[i] == charr[i-1]) ++arr[i];
	}

	for(i=0; i<m; ++i) {
		scanf("%d %d", &a, &b);

		printf("%d\n", arr[b-1]-arr[a-1]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int m, i, a, b, len_charr;
	int *arr;
	char *charr;

	charr = malloc(100001*sizeof(char));
	scanf("%s", charr);
	len_charr = strlen(charr);

	scanf("%d", &m);
	arr = malloc(m*len_charr);
	arr[0] = 0;
	for(i=1; i<len_charr; ++i) {
		arr[i] = arr[i-1];
		if(charr[i] == charr[i-1]) ++arr[i];
	}

	for(i=0; i<m; ++i) {
		scanf("%d %d", &a, &b);

		printf("%d\n", arr[b-1]-arr[a-1]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int m, i, a, b, len_charr;
	int *arr;
	char *charr;

	charr = malloc(100001*sizeof(char));
	scanf("%s", charr);
	len_charr = strlen(charr);

	scanf("%d", &m);
	arr = malloc(len_charr*sizeof(int));
	arr[0] = 0;
	for(i=1; i<len_charr; ++i) {
		arr[i] = arr[i-1];
		if(charr[i] == charr[i-1]) ++arr[i];
	}

	for(i=0; i<m; ++i) {
		scanf("%d %d", &a, &b);

		printf("%d\n", arr[b-1]-arr[a-1]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int m, i, a, b, len_charr;
	int *arr;
	char *charr;

	charr = malloc(100001*sizeof(char));
	scanf("%s", charr);
	len_charr = strlen(charr);

	scanf("%d", &m);
	arr = malloc(m*(len_charr*sizeof(int)));
	arr[0] = 0;
	for(i=1; i<len_charr; ++i) {
		arr[i] = arr[i-1];
		if(charr[i] == charr[i-1]) ++arr[i];
	}

	for(i=0; i<m; ++i) {
		scanf("%d %d", &a, &b);

		printf("%d\n", arr[b-1]-arr[a-1]);
	}

	return 0;
}


#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:16777216")
#include <stdio.h>
#include <string.h>
#include <math.h>

#define PI 3.1415926535897932384

#ifndef ONLINE_JUDGE
	FILE *stream;
#endif

int main()
{
	char str[100001];
	int m;
	int l, r;
	int len;
	int i;
	char currentSym;
#ifndef ONLINE_JUDGE
 	freopen_s(&stream, "D:\\Work\\CodeForces\\input.txt", "rt", stdin);
  	freopen_s(&stream, "D:\\Work\\CodeForces\\output.txt", "wt", stdout);
#endif
	scanf("%s%i", str, &m);

	len = strlen(str);
	currentSym = str[0];
	str[0] = 0;
	for (i = 1; i < len; i++){
		if (str[i] == currentSym)
			str[i] = str[i-1] + 1;
		else{
			currentSym = str[i];
			str[i] = str[i-1];
		}
	}

	for (; m > 0; m--){
		scanf("%i%i", &l, &r);

		printf("%i\n", str[r-1] - str[l-1]);
	}
  	return 0;
}


#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:16777216")
#include <stdio.h>
#include <string.h>
#include <math.h>

#define PI 3.1415926535897932384

#ifndef ONLINE_JUDGE
	FILE *stream;
#endif

int main()
{
	char str[100002];
	int m;
	int l, r;
	int len;
	int i;
	char currentSym;
	int result;
#ifndef ONLINE_JUDGE
 	freopen_s(&stream, "D:\\Work\\CodeForces\\input.txt", "rt", stdin);
  	freopen_s(&stream, "D:\\Work\\CodeForces\\output.txt", "wt", stdout);
#endif
	scanf("%s%i", &str[1], &m);

	len = strlen(&str[1]);
	currentSym = str[1];
	str[1] = 1;
	for (i = 2; i <= len; i++){
		if (str[i] == currentSym)
			str[i] = str[i-1] + 1;
		else{
			currentSym = str[i];
			str[i] = 1;
		}
	}

	for (; m > 0; m--){
		scanf("%i%i", &l, &r);

		result = 0;
		while (l < r){
			if (r - str[r] >= l)
				result += str[r] - 1;
			else
				result += str[r] - str[l];

			r -= str[r];
		}

		printf("%i\n", result);
	}
  	return 0;
}


#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:16777216")
#include <stdio.h>
#include <string.h>
#include <math.h>

#define PI 3.1415926535897932384

#ifndef ONLINE_JUDGE
	FILE *stream;
#endif

int main()
{
	char str[100001];
	int  arr[100000];
	int m;
	int l, r;
	int len;
	int i;
	char currentSym;
#ifndef ONLINE_JUDGE
 	freopen_s(&stream, "D:\\Work\\CodeForces\\input.txt", "rt", stdin);
  	freopen_s(&stream, "D:\\Work\\CodeForces\\output.txt", "wt", stdout);
#endif
	scanf("%s%i", str, &m);

	len = strlen(str);
	currentSym = str[0];
	arr[0] = 0;
	for (i = 1; i < len; i++){
		if (str[i] == currentSym)
			arr[i] = arr[i-1] + 1;
		else{
			currentSym = str[i];
			arr[i] = arr[i-1];
		}
	}

	for (; m > 0; m--){
		scanf("%i%i", &l, &r);

		printf("%i\n", arr[r-1] - arr[l-1]);
	}
  	return 0;
}


#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:16777216")
#include <stdio.h>
#include <string.h>
#include <math.h>

#define PI 3.1415926535897932384

#ifndef ONLINE_JUDGE
	FILE *stream;
#endif

int main()
{
	char str[100001];
	int m;
	int l, r;
	int len;
	int i;
	char currentSym;
	int result;
#ifndef ONLINE_JUDGE
 	freopen_s(&stream, "D:\\Work\\CodeForces\\input.txt", "rt", stdin);
  	freopen_s(&stream, "D:\\Work\\CodeForces\\output.txt", "wt", stdout);
#endif
	scanf("%s%i", str, &m);

	for (; m > 0; m--){
		scanf("%i%i", &l, &r);
		l--;
		r--;

		currentSym = str[l];
		len = 1;
		result = 0;
		for (i = l+1; i <= r; i++){
			if (str[i] == currentSym)
				len++;
			else{
				result += len - 1;
				currentSym = str[i];
				len = 1;
			}
		}
		result += len - 1;

		printf("%i\n", result);
	}
  	return 0;
}


#include<stdio.h>
int scan()
{
int t=0;
char c;
c=getchar_unlocked();
while(c<'0' || c>'9')
c=getchar_unlocked();
while(c>='0' && c<='9')
{
t=(t<<3)+(t<<1)+c-'0';
c=getchar_unlocked();
}
return(t);
}
int main()
{
    char s[100020];
    int i,j,l,r,m;
    scanf("%s",s);
   // puts(s);
    m=scan();
    while(m--)
    {
        l=scan();
        r=scan();
        int count=0;
        for(i=l-1;i<r-1;i++)
        {
            if(s[i]==s[i+1])
            count++;
        }
        printf("%d\n",count);
    }
}


#include<stdio.h>
int main()
{
    char s[100020];
    int i,j,l,r,m;
    scanf("%s",s);
   // puts(s);
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d %d",&l,&r);
        int count=0;
        for(i=l-1;i<r-1;i++)
        {
            if(s[i]==s[i+1])
            count++;
        }
        printf("%d\n",count);
    }
}


#include<stdio.h>
#include<string.h>
int main()
{
    char str[1000000],ch;
    int arr[100000];
    arr[0]=0;
    int i,l,t,k,m;
    scanf("%s",str);
    scanf("%d",&m);
    l=strlen(str);
    for(i=1;i<l;i++)
    {
        arr[i]=arr[i-1];
        if(str[i]==str[i-1])
            arr[i]++;
    }
    while(m--)
    {
        scanf("%d %d",&k,&l);
        printf("%d\n",arr[l-1]-arr[k-1]);;
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char str[1000000],ch;
    int t,i,j,k,l,m,n,count=0;
    scanf("%s",str);
    scanf("%d",&t);
    while(t--)
    {
        count=0;
        scanf("%d %d",&k,&l);
        for(i=k-1;i<l-1;i++)
        {
            if(str[i]==str[i+1])
                count++;
        }
        printf("%d\n",count);
    }
    return 0;
}