var
a,m,w,t:longint;
i,j:longint;
out:array[1..50000] of int64;
sta:array[1..50000] of int64;
procedure solve(n:longint);
var
z,u:longint;
begin
if n=0 then
exit;
solve(n div 2);
w:=15000;
while out[w]=0 do dec(w);
for i:=1 to w do
for j:=1 to w do
if n mod 2=0
then
sta[i+j-1]:=sta[i+j-1]+out[i]*out[j]
else
sta[i+j-1]:=sta[i+j-1]+out[i]*out[j]*m;
u:=15000;
while (out[u]=0)and(sta[u]=0) do
dec(u);
for i:=1 to 15000 do
begin
out[i]:=sta[i] mod 10;
sta[i+1]:=sta[i+1]+sta[i] div 10;
end;
fillchar(sta,sizeof(sta),0);
end;
begin
assign(input,'cruel1.in');
assign(output,'cruel1.out');
reset(input);
rewrite(output);
read(m,a);
out[1]:=1;
solve(a);
t:=0;
for i:=15000 downto 1 do
begin
if (out[i]<>0)or(t=1) then
begin
t:=1;
write(out[i]);
w:=w+1;
end;
if (w mod 70=1)and(w<>1) then writeln;
end;
close(input);
close(output);
end.