program zht;
var
l,i,j,n,zs:longint;
z:array[1..33] of integer;
a:ansistring;
begin
assign(input,'testled.in');
assign(output,'testled.out');
reset(input);
rewrite(output);
readln(l);
readln(a);
for i:=1 to l do
z[i]:=ord(a[i])-48;
readln(n);
readln(a);
for i:=1 to n do
begin
if a[i]='a' then begin for j:=1 to l do z[j]:=1;continue;end;
if a[i]='b' then begin for j:=1 to l do z[j]:=0;continue;end;
if a[i]='c' then begin for j:=1 to l do if z[j]=1 then z[j]:=0 else z[j]:=1;continue;end;
if a[i]='1' then begin for j:=l downto 1 do if j mod 2=1 then if z[l-j+1]=1 then z[l-j+1]:=0 else z[l-j+1]:=1;continue;end;
if a[i]='2' then begin for j:=l downto 1 do if j mod 2=1 then if z[l-j+1]=1 then z[l-j+1]:=0 else z[l-j+1]:=1;continue;end;
for j:=1 to ord(a[i])-48 do
z[j]:=0;
for j:=l downto l-(ord(a[i])-48)+1 do
z[j]:=1;
end;
for i:=1 to l do
begin
write(z[i]);
if z[i]=1 then zs:=zs+1;
end;
writeln;
writeln(zs);
close(input);
close(output)
end.