program cogs1674;
const
maxn=100;
var
s:char;
total,m,n,i,j:longint;
a:array[1..maxn] of char;
procedure zuo(s:char);
var
i,j,code,x:longint;
begin
if (ord(s)<51) or (ord(s)>96) then
begin
case s of
'a':for i:=1 to n do a[i]:='1';
'b':for i:=1 to n do a[i]:='0';
'c':for i:=1 to n do if a[i]='1' then a[i]:='0' else a[i]:='1';
'1':for i:=n downto 1 do
if (n-i+1) mod 2=1 then
if a[i]='1' then a[i]:='0' else a[i]:='1';
'2':for i:=n downto 1 do
if (n-i+1) mod 2=0 then
if a[i]='0' then a[i]:='1' else a[i]:='0';
end;
end else
begin
val(s,x,code);
for i:=1 to x do
begin
a[n-i+1]:='1';
a[i]:='0';
end;
end;
end;
begin
assign(input,'testled.in'); reset(input);
assign(output,'testled.out'); rewrite(output);
readln(n);
for i:=1 to n do
read(a[i]);
readln(m);
for i:=1 to m do
begin
read(s);
zuo(s);
end;
total:=0;
for i:= 1 to n do
begin
write(a[i]);
if a[i]='1' then inc(total);
end;
writeln;
writeln(total);
close(input); close(output);
end.