#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,q;
cin>>n>>q;
string s;
cin>>s;
string w;
cin>>w;
for(int i=0;i<q;i++)
{
if(w[i]=='1')
{
reverse(s.begin(), s.end());
}
else if(w[i]=='2')
{
for(int i=0;i<n;i++)
{
if(s[i]=='0')
s[i]='1';
else if(s[i]=='1')
s[i]='0';
}
}
}
cout<<s;
return 0;
}
TLE了,50分