var
a,c,w,w1,wei,n,p:longint;
f:array[1..2200]of int64;
b:int64;
begin
assign(input,'cruel1.in');
reset(input);
assign(output,'cruel1.out');
rewrite(output);
read(n,p);
f[1]:=n;
w:=1;
while f[w]>=10000000 do
begin
f[w+1]:=f[w] div 10000000;
f[w]:=f[w] mod 10000000;
inc(w);
end;
w1:=w;
for p:=2 to p do
begin
b:=0;
for a:=1 to w+w1 do
begin
f[a]:=f[a]*n+b;
b:=f[a] div 10000000;
f[a]:=f[a] mod 10000000;
end;
w1:=a;
while f[w1]=0 do dec(w1);
end;
write(f[w1]);
b:=1;wei:=1;
while f[w1]>=b*10 do
begin
b:=b*10;
inc(wei);
end;
for a:=w1-1 downto 1 do
begin
b:=1000000;
for c:=1 to 7 do
begin
write((f[a] div b) mod 10);
b:=b div 10;
inc(wei);
if wei mod 70=0 then writeln;
end;
end;
writeln;
close(input);close(output);
end.