#include <stdio.h>
void sort1(char *S) {
int length = strlen(S);
for (int i = 0; i < length - 1; i += 2) {
char temp = S[i];
S[i] = S[i + 1];
S[i + 1] = temp;
}
}
void sort2(char *S){
int length = strlen(S);
for (int i = 0; i < length - 1; i += 2) {
if(S[i]>S[i+1]){
char temp = S[i];
S[i] = S[i + 1];
S[i + 1] = temp;
}
}
}
void sort3(char *S){
int length = strlen(S);
char s1[100],s2[100];
int mid=length/2;
for (int i = 0; i < mid; i += 1) {
s1[i]= S[i];
}
for (int i = 0; i < length - mid; i++) {
s2[i] = S[mid + i];
}
for (int i = 0; i < length; i += 1) {
if(i%2==0){
S[i]=s1[i/2];
}else{
S[i]=s2[i/2];
}
}
}
int main(void) {
char S[100];
int k, j = 0;
scanf("%[^\n]", S);
scanf("%d", &k);
int arr[k];
for (int i = 0; i < k; i++) {
scanf("%d", &arr[i]);
}
while (k--) {
if (arr[j] == 0) {
sort1(S);
}else if(arr[j] == 1){
sort2(S);
}else if(arr[j] == 2){
sort3(S);
}
j++;
}
printf("%s", S);
}