var
	n, m, k, i, pr, u, j: longint;
	a: array [0..10000] of longint;
	ans: int64;

begin
//        reset(input, 'a.in');
//	rewrite(output, 'a.out');
	readln(n, m, k);
        if (k * 2 >= n) or (k * 2 >= m) then begin
                write(0);
                halt;
        end;
	for i := 2 * k + 1 to n - 1 do begin
		pr := 2; u := i;
		while (u > 1) do begin
			while u mod pr = 0 do begin
				inc(a[pr]);
                u := u div pr;
			end;
			inc(pr);
		end;
        if u > 1 then inc(a[u]);
	end;
    for i := 2 to n - 2 * k - 1 do begin
    	pr := 2; u := i;
		while (u > 1) do begin
			while u mod pr = 0 do begin
				dec(a[pr]);
                u := u div pr;
			end;
			inc(pr);
		end;
        if u > 1 then dec(a[u]);
    end;
    ans := 1;
    for i := 1 to n - 1 do
    	if a[i] > 0 then begin
    		for j := 1 to a[i] do
    			ans := (ans * int64(i)) mod 1000000007;
    	  	a[i] := 0;
      	end;

   	for i := 2 * k + 1 to m - 1 do begin
		pr := 2; u := i;
		while (u > 1) do begin
			while u mod pr = 0 do begin
				inc(a[pr]);
                u := u div pr;
			end;
			inc(pr);
		end;
        if u > 1 then inc(a[u]);
	end;
    for i := 2 to m - 2 * k - 1 do begin
    	pr := 2; u := i;
		while (u > 1) do begin
			while u mod pr = 0 do begin
				dec(a[pr]);
                u := u div pr;
			end;
			inc(pr);
		end;
        if u > 1 then dec(a[u]);
    end;
    for i := 1 to m - 1 do
    	if a[i] > 0 then begin
    		for j := 1 to a[i] do
    			ans := (ans * int64(i)) mod 1000000007;
    	  	a[i] := 0;
      	end;
  	write(ans);
end.


{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
    n,m : integer;
function min(x,y : integer) : integer;
begin
    if x<y then min := x
    else min := y;
end;
begin
     read(n,m);
     if (m = 0)   then begin
        write(n,' ',n);
        halt;
     end;
     if n = 0 then write('Impossible')
     else
     write(min(n,m) + abs(n-m),' ',m + (n - 1));
end.


var m,d,a,n: longint;
begin
read(m,d);
if m=1 then m:=31;
if m=2 then m:=28;
if m=3 then m:=31;
if m=4 then m:=30;
if m=5 then m:=31;
if m=6 then m:=30;
if m=7 then m:=31;
if m=8 then m:=31;
if m=9 then m:=30;
if m=10 then m:=31;
if m=11 then m:=30;
if m=12 then m:=31;
m:=m-8+d;
if m mod 7=0 then m:=m div 7+1 else m:=m div 7+2;
write(m);
readln;
end.


uses math;
const
      oo=high(longint);
      _oo=high(int64);
      roo=1e30;
      dx:array[0..7] of longint=(-1,0,1,0,-1,1,1,-1);
      dy:array[0..7] of longint=(0,1,0,-1,1,1,-1,-1);
type point=record x,y:longint; end;
     rpoint=record x,y:double; end;
var f,g:text;
    fi,fo:string;
    a,b,k,i,j,l,r,mid:longint;
    pr:array[0..2000000] of longint;
procedure closefile; begin close(g); close(F); end;
function ok(ans:longint):boolean;
var i:longint;
begin
        for i:=a to b-ans+1 do
            if pr[i+ans-1]-pr[i-1]<k then exit(false);
        exit(true);
end;
begin
        randomize;
       // {$IFNDEF ONLINE_JUDGE} fi := 'i.inp'; fo := ''; {$ENDIF}
        assign(f,fi); reset(f);
        assign(g,fo); rewrite(g);
                readln(f,a,b,k);
                for i:=2 to 2*b do pr[i]:=1;
                for i:=2 to 2*b do
                        if i*i>2*b then break
                        else if pr[i]=1 then begin
                            j:=i+i;
                            while j<=2*b do begin
                                pr[j]:=0;
                                j:=j+i;
                            end;
                        end;
                for i:=1 to 2*b do pr[i]:=pr[i]+pr[i-1];
                l:=1; r:=b-a+1;
                while l<r do begin
                    mid:=(l+r) shr 1;
                    if ok(mid) then r:=mid
                    else l:=mid+1;
                end;
                if ok(l) then writeln(g,l)
                else writeln(g,-1);

        closefile;
end.


var
  s,b:string;
  i,j,n,m:integer;
begin
  readln(s); b:=' a e i u o ';
  if length(s)=1 then begin
  if (pos(' '+s+' ',b)<>0) or (s[1]='n') then writeln('YES') else writeln('NO');
  end else begin
  for i:=2 to length(s) do
     if (pos(' '+s[i]+' ',b)=0) and (pos(' '+s[i-1]+' ',b)=0) and (s[i-1]<>'n') then begin write('NO'); exit;  end;
  if (pos(' '+s[length(s)]+' ',b)=0) and (s[length(s)]<>'n') then
  writeln('NO') else writeln('YES'); end;
end.


type tlist=record
      last,pred,y:array[0..1000000] of longint;
      size:longint;
end;
var v,k,n,m,x,y,i:longint;
    col:array[0..1000000] of longint;
    used:array[0..1000000] of boolean;
    g:tlist;
    any:boolean;
  procedure add(x,y:longint);
   begin
     inc(g.size);
     g.pred[g.size]:=g.last[x];
     g.y[g.size]:=y;
     g.last[x]:=g.size;
   end;
 begin
   read(n,m);
   for i:=1 to m do
    begin
      read(x,y);
      add(x,y);
      add(y,x);
    end;
   for i:=1 to n do
    begin
      col[i]:=1;
    end;
   while true do
    begin
      any:=false;
      for v:=1 to n do
       begin
         x:=g.last[v];
         k:=0;
         while x<>0 do
          begin
            if col[g.y[x]]=col[v] then k:=k+1;
            x:=g.pred[x];
          end;
         if k>1 then
          begin
            col[v]:=3-col[v];
            any:=true;
          end;
       end;
      if not any then break;
    end;
   for i:=1 to n do
    write(col[i]-1);
   writeln;
 end.


var

x,y:array[1..3] of longint;
check:array[1..3] of integer;
ans,ravx,ravy,i:integer;

begin

for i:=1 to 3 do
 begin
 read(x[i],y[i]);
 readln;
 end;

if (x[1]=x[2]) then inc(ravx);
if (x[2]=x[3]) then inc(ravx);
if (ravx<>2) and (x[1]=x[3]) then inc(ravx);

if (y[1]=y[2]) then inc(ravy);
if (y[2]=y[3]) then inc(ravy);
if (ravy<>2) and (y[1]=y[3]) then inc(ravy);

if (ravx=2) or (ravy=2) then ans:=1;

if (ravx=1) and (ravy=1) then ans:=2;

if (ravx=1) and (ravy=0) then
 begin
 if (x[1]=x[2]) then
  begin
  check[1]:=1;
  check[2]:=2;
  check[3]:=3;
  end;
 if (x[2]=x[3]) then
  begin
  check[1]:=2;
  check[2]:=3;
  check[3]:=1;
  end;
 if (x[1]=x[3]) then
  begin
  check[1]:=1;
  check[2]:=3;
  check[3]:=2;
  end;
 if (y[check[3]]<y[check[2]]) and (y[check[3]]>y[check[1]]) then ans:=3;
 if (y[check[3]]>y[check[2]]) and (y[check[3]]<y[check[1]]) then ans:=3;
 if (ans=0) then ans:=2;
 end;

if (ravy=1) and (ravx=0) then
 begin
 if (y[1]=y[2]) then
  begin
  check[1]:=1;
  check[2]:=2;
  check[3]:=3;
  end;
 if (y[2]=y[3]) then
  begin
  check[1]:=2;
  check[2]:=3;
  check[3]:=1;
  end;
 if (y[1]=y[3]) then
  begin
  check[1]:=1;
  check[2]:=3;
  check[3]:=2;
  end;
 if (x[check[3]]<x[check[2]]) and (x[check[3]]>x[check[1]]) then ans:=3;
 if (x[check[3]]>x[check[2]]) and (x[check[3]]<x[check[1]]) then ans:=3;
 if (ans=0) then ans:=2;
 end;

if (ravx=0) and (ravy=0) then ans:=3;

write(ans);

end.


var	n,d,i,j:longint;
	s:ansistring;
	a:array[0..105,0..105] of byte;
	lab:array[0..105] of longint;
	procedure xuat;
		begin
			writeln(-1);
			halt;
		end;
	procedure di(o:longint);
	var	i:longint;
		begin
			i:=1;
			while (i<=d) and (o+i<=n) do
			begin
				if a[o,o+i]=1 then
				begin
					if lab[o+i]>lab[o]+1 then
					begin
						lab[o+i]:=lab[o]+1;
						di(o+i);
					end;
				end;
				inc(i);
			end;
		end;
begin
	readln(n,d);
	readln(s);
	fillchar(a,sizeof(a),0);
	if s[1]='0' then xuat;
	for i:=1 to n do
	begin
		j:=1;
		while (j<=d) and (i+j<=n) do
		begin
			if (s[i]='1') and (s[i+j]='1') then a[i,i+j]:=1 else a[i,i+j]:=0;
			inc(j);
		end;
	end;
	fillchar(lab,sizeof(lab),n+1);
	lab[1]:=0;
	di(1);
	if lab[n]>n then xuat else writeln(lab[n]);
end.


uses math;
var
 a : array [0..11111] of longint;
 res0,res1,res2,x0,y0,x1,y1,x2,y2,res,n,i,j,k,m,h,c,x,z : longint;

begin
 readln(n);
 readln(x0, y0);
 readln(x1, y1);
 readln(x2, y2);

 res0:=min(n - (x1+x2), y0);
 res1:=min(n - res0 - x2, y1);

 writeln(res0, ' ', res1, ' ', n - (res1 + res0));
end.


var a1,a2,k1,k2,n:integer;
    l1,l2,l3:integer;
begin
  read(a1, a2, k1, k2, n);
  l1:=n-(k1-1)*a1-(k2-1)*a2;
  if k1<k2 then
    begin
    l2:=n div k1;
    if l2>a1 then l2:=a1;
    n:=n-l2*k1;
    l3:=n div k2;
    if l3>a2 then l3:=a2;
    end
  else
    begin
    l2:=n div k2;
    if l2>a2 then l2:=a2;
    n:=n-l2*k2;
    l3:=n div k1;
    if l3>a1 then l3:=a1;
    end;
  if l1<0 then l1:=0;
  write(l1,' ',l2+l3);
end.


{$APPTYPE CONSOLE}

uses
  SysUtils;
  var a:array[0 .. 10000]of integer;
  n,m,k,count,t ,j,z,i : integer;
begin
 readln(n,m,t);
 count := 0;
 for i:=1 to n do
 begin
  inc(count);
  read(a[count]);
  if a[count] = 1 then dec(count);
 end;
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if a[i]<a[j] then
   begin
    z := a[i];
    a[i] := a[j];
    a[j] :=z;
   end;
 i :=1;
 if m <= t then
 begin
  writeln(0);
  halt;
 end;
 while (i <= count) do
 begin
  t := t - 1 + a[i];
  if t >= m then
  begin
   writeln(i);
   halt;
  end;
  inc(i);
 end;
 writeln(-1);
end.


var
 i,j,n,m,k,kol:longint;
 ans:int64;
 f:boolean;
begin
// assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output);
 readln(n);
 ans:=n;
 while n>1 do
 begin
  for i:=2 to trunc(sqrt(n)) do if n mod i=0 then
  begin
   f:=true;
   break;
  end;
  if not f then i:=n;
  inc(ans,n div i);
  n:=n div i;
  f:=false;
 end;
 writeln(ans);
end.


var
  c : array[1..100000] of char;
  n : 0..100000;

procedure print();
var
  i : 0..100000;
begin
  for i := 1 to n do
    write(c[i]);
  halt;
end;

var
  i, k : 0..100000;
  x : 0..27;
begin
  n := 0;
  k := 0;
  x := 1;
  while not EOLN do
    begin
	  inc(n);
      read(c[n]);

	  if (ord(c[n]) <= 96 + x) and (x <> 27) then
	    begin
		  c[n] := chr(96 + x);
		  inc(x);
		end;
	end;

  if (n < 26) or (x < 27) then
    begin
      writeln('-1');
	  halt;
	end
  else print();

end.


var
 i,a,b,c:longint;
 s:ansistring;
begin
 read(s);
 for i:=1 to length(s) do
 begin
  if i<pos('+',s) then inc(a);
  if (i>pos('+',s))and(i<pos('=',s))then inc(b);
  if i>pos('=',s) then inc(c);
 end;
 if a+b=c then
 begin
  write(s);
  halt;
 end;
 if a+b>c then
 begin
  if a>1 then
  if a-1+b=c+1 then
  begin
   for i:=1 to a-1 do write('|');
   write('+');
   for i:=1 to b do write('|');
   write('=');
   for i:=1 to c+1 do write('|');
   halt;
  end;
  if b>1 then
  if a+b-1=c+1 then
  begin
   for i:=1 to a do write('|');
   write('+');
   for i:=1 to b-1 do write('|');
   write('=');
   for i:=1 to c+1 do write('|');
   halt;
  end;
 end;
 if (a+b<c)and(c>1) then
 begin
  if a+1+b=c-1 then
  begin
   for i:=1 to a+1 do write('|');
   write('+');
   for i:=1 to b do write('|');
   write('=');
   for i:=1 to c-1 do write('|');
   halt;
  end;
  if a+b+1=c-1 then
  begin
   for i:=1 to a do write('|');
   write('+');
   for i:=1 to b+1 do write('|');
   write('=');
   for i:=1 to c-1 do write('|');
   halt;
  end;
 end;
 writeln('Impossible');
end.


                                                                       const eps=1e-10;
                  besk=4000000000000000000; label 1,3,2,44;
            type mas=array[-1000000..1500000+1] of int64; integer=longint;
            var sdvig,start,dl,len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,mesto,num:longint;
            ss3,ss,ss1,ss2:string;
            px,py,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,ll,rr,sum,m,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;
              xa,summ,place,kol,str,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean;  pl:longint;
             oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;
              prost,marked,zan:array[-10..4000000] of boolean;
              lx,rx,ly,ry,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10..550000] of int64;
              ppole:array[-1000..1000000] of char;
              stroka:array[-1000..1000000] of char;
              ot1,otmax,v:extended;
              prof,profil,zzz:array[-10..100,-10..100] of int64;
              sp,sss:array[-10..2000000] of string;
              newpole,pole:array[-1..1100,-1..700] of int64;
              ddpos,dd,ddinv,dnech,poschet,posnechet:array[-10..1900000,0..2,0..2] of int64;
              poss:int64;
              ch:char;
              ff,flagg1:boolean;
              s,znach,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-1000000..4000002] of int64;
              ddd:array[-10..5010,-10..5010] of int64;
             function srav(i,j:longint):boolean;
              begin if (a[i]<a[j])or(a[i]=a[j])and(a1[i]<a1[j])or(a[i]=a[j])and(a1[i]=a1[j])and(a2[i]<a2[j])  then
              srav:=true else srav:=false; end;

            procedure sl (k,l,m:integer);  {k- dlina, l,m - nachalo dvuh blokov}
            begin
            i:=l;j:=m; flag:=true; step:=0;while flag do begin
            if (srav(i,j)) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];end;
            inc(step);inc(i);
            {writeln('step=',step,' i=',i);} end;
            if (not srav(i,j)) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];end;
            inc(step);inc(j);end;
            if  ((i>=l+k) or (j>=m+k)) then flag:=false;
            end;
            if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];inc(step);inc(j);until (j>=m+k);
            if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];inc(step);inc(i);until (i>=l+k);
            end;
            procedure sort(var c:mas);

            begin

            k:=1; repeat
            l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;
            for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i]; end;
            until (k>=n);

            end;

            function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
            function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  end;

            function phi(a,b:double):double; label 222;var p:double;
            begin
              if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;
              if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;
              if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;
              if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;
              if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;
              222: phi:=p;
            end;

            function nod(a,b:int64):int64; var p,t:int64;
            begin
              a:=abs(a); b:=abs(b);
              if (a>0)and(b>0) then
               begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
                p:=a;
               end else if a=0 then p:=b else p:=a;
            nod:=p;
            end;

            function nok(a,b:int64):int64;
            begin  nok:=(a*b) div nod(a,b);  end;

               function degg(a:int64;k:int64):int64; var p:int64;
            begin
             if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul  else
               begin  p:=degg(a,k div 2); degg:=(p*p) mod modul;    end;

            end;

            function zaprmax(left,right:longint):int64;
        begin
           if left>=right then zaprmax:=y[left] else
             begin
                if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else
                 begin
                  if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);
                  if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);

                 end;

             end;

        end;

            procedure udal(ii:longint);
            begin  next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii];  end;

            function nomerr(gr:int64):int64;

            var ot,aa,bb,cc:int64; fl:boolean;
            begin
              aa:=1; bb:=p;  cc:=aa; fl:=false;
              while abs(aa-bb)>1 do
                begin
                   cc:=(aa+bb) shr 1;
                 {  writeln('cc=++ ',cc);
                 }  if y[cc]<gr then aa:=cc else bb:=cc;

                end;
              { writeln(' cc= ',cc);
              } cc:=max(cc-3,0);
               repeat inc(cc) until y[cc]>=gr;
               if y[cc]=gr then fl:=true else fl:=false;
               { if fl then nomerr:=a1[cc] else nomerr:=-1000;}
               nomerr:=cc;
            end;

            function pprost(pp:longint):boolean;
            var i,j,t:longint; tt:extended; fl:boolean;
            begin
              tt:=pp;
              tt:=sqrt(tt);
              fl:=true;
              for i:=2 to round(tt) do if pp mod i=0 then  fl:=false;

             pprost:=fl;

            end;

            function gl(c:char):boolean;
            begin
             if (c='a')or (c='o')or(c='e')or(c='i')or(c='u') then gl:=true else gl:=false;

            end;

      function    fff(ch:char):longint;
    begin
      if ch='R' then fff:=0;
      if ch='G' then fff:=1;
      if ch='B' then fff:=2;

    end;

            begin

           {  assign (input,'D:\Projects\input.txt');reset(input);
               assign (output,'D:\Projects\output.txt'); rewrite(output);
            }
               readln(n,kk);
               readln(ss);
               q:=1; sss[1]:=ss;
              for step:=1 to 100000 do
                begin
                   ff:=false;
                   for i:=1 to q do
                      begin
                          if q>=kk then goto 2;
                          t:=length(sss[i]);
                          { writeln('work with   ',sss[i]);  }
                            for j:=0 to t do
                               begin
                                  ss2:=copy(sss[i],1,j); ss3:=copy(sss[i],j+2,t-j-1);
                                 { writeln(ss2,' = ',ss3);
                                 } ss1:=ss2+ss3;
                                  { writeln(ss1);
                                  } flag:=false;
                                   for k:=1 to q do if ss1=sss[k] then flag:=true;
                                   if not flag then
                                     begin
                                       inc(q); sss[q]:=ss1; ff:=true;
                                      { writeln('**add**=   ',ss1); }
                                     end;
                                 {  writeln(ss1,' ',flag); }
                               end;

                      end;
                   if not ff and(q<kk) then begin  writeln('-1'); goto 1;  end;
                end;

 2:   {  writeln('q= ',q);
 for i:=1 to q do writeln(sss[i]);
} ot:=0;
 for i:=1 to kk do ot:=ot+length(ss)-length(sss[i]);
 writeln(ot);

             1: close (output);
                 end.


var
    f:array[0..200001] of int64;
    i,j,n,m,x,y:longint;
    sum,s1,s2,t:int64;
    bz:boolean;
procedure px(xx,yy:longint);
var
    x,y,m,t:longint;

begin
    x:=xx;y:=yy;
    m:=f[(x+y) div 2];
    repeat
        while f[x]<m do inc(x);
        while f[y]>m do dec(y);
        if x<=y then begin
            t:=f[x];f[x]:=f[y];f[y]:=t;
            inc(x);dec(y);
        end;
    until x>y;
    if x<yy then px(x,yy);
    if xx<y then px(xx,y);
end;
begin;
    readln(n,m);
    for i:=1 to m do begin
        readln(x,y);
        if y=0 then begin
            y:=n;x:=1-x;
        end;
        if x=0 then f[i]:=y else f[i]:=y+n;
    end;
    px(1,m);
    bz:=false;
    for i:=m+1 to 2*m do f[i]:=f[i-m]+2*n;f[2*m+1]:=maxlongint*maxlongint;
    for i:=1 to m do if f[i+1]-f[i]>n then begin
        bz:=true;
        x:=i;y:=i+1;
        break;
    end;
    if bz then begin
        if f[y]-f[x]=2*n then writeln(int64(m)*(m-1)*(m-2) div 6) else begin
            t:=f[x];s1:=0;
            while f[x]=t do begin
                dec(x);inc(s1);
            end;
            t:=f[y];s2:=0;
            while f[y]=t do begin
                inc(y);inc(s2);
            end;
            writeln(s1*s2*(m-s1-s2) + (s1-1)*s1 div 2*s2 + (s2-1)*s2 div 2*s1);
        end;
    end else begin
        j:=1;sum:=0;
        for i:=1 to m do begin
            while f[j]-f[i]<n do inc(j);
            sum:=sum+int64(j-i-1)*(j-i-2) div 2;
        end;
        writeln(int64(m)*(m-1)*(m-2) div 6-sum);
    end;
end.


program qwe;
{$APPTYPE CONSOLE}
{$MAXSTACKSIZE $00200000}
{$O-}

uses
  SysUtils,
  Math;

//it is a big shablon. if you see any strange function, never mind

const //base = 1000000007;
 eps = 1e-8;
 inf = 1 shl 30;

type
 TArray = array[0..10000010] of integer;
 int53 = int64;
 itneger = integer;
 point = record
  x, y: integer;
 end;

function less(x, y: point): boolean;
begin
 if (x.x < y.x) or ((x.x = y.x) and (x.y < y.y)) then result := true else result := false;
end;

procedure swap(var x, y: integer);
var
 z: integer;
begin
 z := x;
 x := y;
 y := z;
end;

procedure swap64(var x, y: int64);
var
 z: int64;
begin
 z := x;
 x := y;
 y := z;
end;

procedure swapex(var x, y: extended);
var
 z: extended;
begin
 z := x;
 x := y;
 y := z;
end;

procedure swapp(var x, y: point);
var
 z: point;
begin
 z := x;
 x := y;
 y := z;
end;

var
 base, n, b, i, kol: integer;
 d: array[1..555] of integer;
 flag: boolean;

function pow(a, b: integer): integer;
var
 dega, res: int64;
begin
 res := 1;
 dega := a;
 while b > 0 do begin
  if odd(b) then
  res := (res * dega) mod base;
  dega := (dega * dega) mod base;
  b := b shr 1;
 end;
 result := res mod base;
end;

begin
 {$IFNDEF ONLINE_JUDGE}
 reset(input, 'input.txt');
 rewrite(output, 'output.txt');
 {$ENDIF}
 read(n, b);
 if n = 1 then
 begin
  writeln(b - 1);
  halt(0);
 end;
 dec(b);
 inc(n);
 i := 2;
 while i * i <= n do
 begin
  if n mod i = 0 then
  begin
   writeln(-1);
   halt;
  end;
  inc(i);
 end;
 base := n;
 dec(n);
 i := 1;
 kol := 0;
 while (i - 1) * (i - 1) <= n do
 begin
  if n mod i = 0 then
  begin
   inc(kol);
   d[kol] := i;
  end;
  inc(i);
 end;
 for i := 1 to kol do
 d[kol + i] := n div d[kol + 1 - i];
 kol:= kol * 2 - 1;
 flag := false;
 repeat
  if b mod base <> 0 then
  begin
   flag := true;
   for i := 1 to kol do
   flag := flag and (pow(b, d[i]) <> 1);
  end;
  dec(b);
 until ((flag = true) or (b = 0));
 if flag then writeln(b + 1) else
 begin
  writeln(-1);
  halt;
 end;
end.


{$R+}
{$APPTYPE CONSOLE}
USES SysUtils, Math;
 var a, b, k, l: int64;
     i, j: integer;
     s1, s2 : string;

begin
{$IFNDEF ONLINE_JUDGE}
Reset(input, 'input.txt');
Rewrite(output, 'output.txt');
{$ENDIF}
read(a, b);
k := a - b;
s1 := IntToStr(a);
s2 := IntToStr(k);
i := length(s1);
l := 0;
while (s1[i] = '9') and  (i > 1) do begin dec(i);inc(l);end;
if s1[i] = '9' then inc(l);

if l >= length(s1) - 1  then begin write(s1);exit;end;

if length(s2) < length(s1) then  begin
if s1[1] > '1' then write(StrToInt(s1[1]) - 1);
for i := 1 to length(s1) - 1 do write('9');

exit;
end;
i := 1;
while (s1[i] = s2[i]) and (i < length(s1)) do inc(i);
if (i = length(s1)) and (s1[i] = s2[i]) then begin write(s1);exit;end;
  if i = length(s1) then begin write(s1);exit;end;
 for j := 1 to i - 1 do write(s1[j]);
 l := 0;

 j := i;
 while (s1[j] = '9') and (j < length(s1)) do inc(j);
 if (j = length(s1)) and (s1[j] = '9') and (s1[i] = '9') then
 begin
   for j := i to length(s1) do write(9);
     exit;
 end;

write(StrToInt(s1[i]) - 1);
 inc(i);
for j := i to length(s1) do write(9);

end.


const fi='520B.inp'; fo='520B.out';
var n,m,s:integer;

procedure input;
var f:text;
 begin
   {assign(f,fi);
   reset(f);}
   readln(n,m);
   //close(f);
 end;

procedure run;
var a,t:integer;
 begin
   s:=0;
   while m>n do
    begin
      if odd(m) then
       begin
         inc(s);
         m:=m+1;
       end;
      m:=m shr 1;
      inc(s);
    end;
   s:=s+n-m;
 end;

procedure output;
var f:text;
 begin
   {assign(f,fo);
   rewrite(f);}
   writeln(s);
   //close(f);
 end;

BEGIN
  input;
  run;
  output;
END.


var
     a:array [1..111] of Longint;
     i,j,T,N,X,Ans:Longint;
begin
     Readln(N);
     for i:=1 to N do
     Read(a[i]);
     Readln(T);
     for i:=1 to N-1 do
     for j:=i+1 to N do
     if a[i]>a[j] then begin
                            X:=a[i];
                            a[i]:=a[j];
                            a[j]:=X;
                        end;
     Ans:=1;
     for i:=1 to N-1 do
     for j:=i+1 to N do
     if a[j]-a[i]<=T then
     if j-i+1>Ans then Ans:=j-i+1;
     Writeln(Ans);
 end.


var s:array[1..4]of longint;
    i,j,k:byte;
begin
    readln(s[1],s[2],s[3],s[4]);
    k:=0;
    for i:=1 to 3 do
        for j:=i+1 to 4 do
            if s[i]=s[j] then
                inc(k);
    case k of
        0:writeln(0);
        1:writeln(1);
        2,3:writeln(2);
        6:writeln(3);
    end;
    readln;
end.


   const eps=0.000000000001;  besk1=8000000000000000000;  nn=200000;
   modul=1000000007;
   label 1,2;
    type
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var qq,xx,q,pos,left,right,amax,ost,h,tt,t1,pp,p,aa,bb,cc,kk,dist,pmax,imax,p1,p2,p3,p4,t,l,ot,nm,n,s1,s2,m,s,cen,t2,i1,besk:int64;
    newug,ugol,newdl,dloch,dugol,ist,jst,ifin,jfin,newnapx,newnapy,napx,napy,jj,step, k,ii,i,j:longint;
     pr,prmax,v,aaa,bbb,ccc:extended; hhh:zap;
     dl,ochnewi,ochnewj,xxx,yyy,ochi,ochj,c,y,z,newoch,och,x,aold,b,a:array[-100000..2000000] of int64;
   stpr,stoim,blup,bldown, blright, blleft, ppole,vol:array[-10..1200,-10..1200] of int64;
   marked:array[-10..1100,-10..1100] of boolean;
    sss, ss1,ss2:string;
    sa,sb,pra,prb,suma,sumb,ota,otb,mmax,mmin,smax,smin:array[-100..200000] of extended;
     fl:array[0..200] of boolean;
    ss:string;ch3,ch,ch1,ch2:char;
    pole :array [-10..2000] of char;
    maxpr:array[0..nn] of string;
    str:array[0..nn] of string;
     tt1,tt2,disk,v0,v1,s0,t0:extended;
     zv:point;
     newx,newy,yy:array[-1..200000] of int64;

     yot:double;
       flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }

read(aa,bb,n,xx);
if  aa=1 then pp:=n mod modul else
begin
   p1:=((degg(aa,n)-1+modul) mod modul );
   p2:=degg(aa-1,modul-2);
   pp:=p1*p2 mod modul;

end;

 {writeln('pp= ',pp);
} qq:=degg(aa,n);
 writeln(((qq*xx) mod modul+bb*pp) mod modul);

   1:          close(output);
end.


var g:array[-10..120] of longint;
    fd,ed:array[-10..120] of extended;
    f:array[-10..50,-10..50,-10..50] of extended;
    n:array[-10..50] of longint;
    d,range:array[-10..60] of extended;
    tower:array[-10..400] of longint;
    ans:extended;

procedure openfile;
  begin
    assign(input,'E.in'); reset(input);
    assign(output,'E.out'); rewrite(output);
  end;

procedure endfile;
  begin
    close(input); close(output);
  end;

procedure init;
  var i:longint;
  begin
    readln(n[1],n[2],n[3]);
    readln(range[1],range[2],range[3]);
    readln(d[1],d[2]);
    for i:=1 to 10 do g[i]:=2;
    for i:=1 to 3 do range[i]:=sqrt(range[i]*range[i]-1);
  end;

procedure check;
  var i,j,k:longint;
      l,r,ll,rr:extended;
  begin
    for i:=1 to 10 do begin
      l:=i-range[1]; r:=i+range[1];
      fd[i]:=r-l;
      for j:=1 to n[3] do begin
        ll:=tower[j]-range[3]; rr:=tower[j]+range[3];
        if (r<ll)or(l>rr) then continue;
        if (ll>l) then begin
          if (rr<r) then fd[i]:=fd[i]+rr-ll
            else fd[i]:=fd[i]+r-ll;
        end
        else begin
          if (rr<r) then fd[i]:=fd[i]+rr-l
            else fd[i]:=fd[i]+r-l;
        end;
      end;
      fd[i]:=fd[i]*d[1];
      l:=i-range[2]; r:=i+range[2];
      ed[i]:=r-l;
      for j:=1 to n[3] do begin
        ll:=tower[j]-range[3]; rr:=tower[j]+range[3];
        if (r<ll)or(l>rr) then continue;
        if (ll>l) then begin
          if (rr<r) then ed[i]:=ed[i]+rr-ll
            else ed[i]:=ed[i]+r-ll;
        end
        else begin
          if (rr<r) then ed[i]:=ed[i]+rr-l
            else ed[i]:=ed[i]+r-l;
        end;
      end;
      ed[i]:=ed[i]*d[2];
    end;
    for i:=0 to 10 do
      for j:=0 to n[1] do
        for k:=0 to n[2] do
          f[i,j,k]:=-1e20;
    f[0,n[1],n[2]]:=0;
    for i:=0 to 9 do
      for j:=0 to n[1] do
        for k:=0 to n[2] do begin
          if f[i+1,j,k]<f[i,j,k] then f[i+1,j,k]:=f[i,j,k];
          if g[i+1]>=1 then begin
            if k>0 then
              if f[i+1,j,k-1]<f[i,j,k]+ed[i+1] then
                f[i+1,j,k-1]:=f[i,j,k]+ed[i+1];
            if j>0 then
              if f[i+1,j-1,k]<f[i,j,k]+fd[i+1] then
                f[i+1,j-1,k]:=f[i,j,k]+fd[i+1];
          end;
          if g[i+1]>=2 then begin
            if k>1 then
              if f[i+1,j,k-2]<f[i,j,k]+ed[i+1]+ed[i+1] then
                f[i+1,j,k-2]:=f[i,j,k]+ed[i+1]+ed[i+1];
            if j>1 then
              if f[i+1,j-2,k]<f[i,j,k]+fd[i+1]+fd[i+1] then
                f[i+1,j-2,k]:=f[i,j,k]+fd[i+1]+fd[i+1];
            if (k>0)and(j>0) then
              if f[i+1,j-1,k-1]<f[i,j,k]+fd[i+1]+ed[i+1] then
                f[i+1,j-1,k-1]:=f[i,j,k]+fd[i+1]+ed[i+1];
          end;
        end;
    if f[10,0,0]>ans then ans:=f[10,0,0];
  end;

procedure dfs(x,y:longint);
  begin
    if x=11 then begin
      if y=n[3] then check;
      exit;
    end;
    dfs(x+1,y);
    g[x]:=1;
    tower[y+1]:=x;
    dfs(x+1,y+1);
    g[x]:=0;
    tower[y+2]:=x;
    dfs(x+1,y+2);
    g[x]:=2;
  end;

begin
  //openfile;
  init;
  dfs(1,0);
  writeln(ans:0:8);
  //endfile;
end.


Var n,k,m,a,b,tmin,sm,pm,sd,pd,spusc:integer;
Procedure Nps(var p,s,kv:integer);
  var i,j,sum:integer;
         b:boolean;
  begin
    sum:=0;
    b:=false;
    for i:=1 to n do
      begin
        if b then break;
        for j:=1 to m do
          begin
            sum:=sum+k;
            if kv-sum <= 0 then
              begin
                p:=i;
                s:=j;
                b:=true;
                break;
              end;
          end;
      end;
  end;
Begin
  Readln(n,m,k);
  Readln(a,b);
  Nps(pm,sm,a);
  Nps(pd,sd,b);
  tmin:= abs((pd-pm)*15);
  if pd>pm then  if (n-pd+pm)*15< tmin then tmin:=(n-pd+pm)*15
                             else
 else if (n-pm+pd)*15<tmin then tmin:=(n-pm+pd)*15;
  if tmin=0 then
    begin
      spusc:=abs((sd-sm)*5);
      if abs(sd-sm)+10<spusc then spusc:=abs((sd-sm))+10;
      tmin:=spusc;
    end
  else
    begin
      if sm>3 then spusc:=sm-1+10
        else spusc:=(sm-1)*5;
      tmin:=tmin+spusc;
      if sd>3 then spusc:=sd-1+10
        else spusc:=(sd-1)*5;
      tmin:=tmin+spusc;
    end;
  Writeln(tmin);
End.


var
    s : string;
    i : longint;
begin
    readln(s);
    for i:=1 to length(s) do
    begin
        if (s[i]='a') and (s[i+1]='t') and (i<>1) and (i+1<>2) and (i<>length(s)-1) and (i+1<>length(s)) then
        begin
            s[i]:='@';
            delete(s,i+1,1);
            break;
        end;
    end;
    for i:=1 to length(s) do
    begin
        if (s[i]='d') and (s[i+1]='o') and (s[i+2]='t') and (i<>1) and (i+1<>2) and (i+2<>3) and (i<>length(s)-2) and (i+1<>length(s)-1) and (i+2<>length(s)) then
        begin
            s[i]:='.';
            delete(s,i+1,2);
        end;
    end;
    write(s);
end.


                    {$APPTYPE CONSOLE}
const  besk=2000000000{000000000};
 label 1,2,3,4;
var k,nn,n,i10,i100,n1,dl,kol,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,i,j,start,finish:longint;
nach,kon,t,cc,m1,pl,sum,p1,p2,m,k2,r,ot,aa,bb,x1,y1,x0,y0,ll,rr,d1,d2,kolvyk,xx2,q,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;
mon1,mon2,day1,day2,god1,god2,kk,mnog,koef:int64;
fl0,fl10,fl100,flag2,flag1,flag:boolean;
ott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;
dd,otdd,b,c:array[-10..200,-10..200] of int64;
y,x:extended;
a,zz,xx,yy,z1,z: array[-10..500000] of int64;
gr1,gr: array[-50..700,-50..700] of char;
ee,deg,marked:array[-100000..250000] of int64;
{ss:array[0..2000000] of char; }
sss1,sss:string;
ab:array[-100..200,-100..201,-100..201] of char;
ch11,ch12,ch1,ch:char;
sl,sr :array[-10 ..200000] of int64;
stolb,str:array[-10..500] of boolean;
ssot:array[-1000..1100000] of char;
p,stepen:array[0..1000] of int64;
name:array[0..2000] of string;
function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  end;

    function nod(a,b:int64):int64; var p,t:int64;
begin if (a>0)and(b>0) then
   begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
    p:=a;
   end else if a=0 then p:=b else p:=a;
nod:=p;
end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
{ assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
 }
                              modul:=1000000007 ;
 readln(n,m);
 for i:=1 to n do begin for j:=1 to m do  read(gr[i,j]); readln; end;

 for i:=1 to n do for j:=1 to m do if gr[i,j]='S' then  str[i]:=true;
  for i:=1 to n do for j:=1 to m do if gr[i,j]='S' then  stolb[j]:=true;
for i:=1 to n do if str[i] then inc(p1);
for i:=1 to m do if stolb[i] then inc(p2);
{writeln(p1,' ',p2);
}writeln(n*m-p1*p2);

   1:          close(output);

end.


var
  a,q:int64;

begin
  readln(a);
  if a mod 2 = 0 then q:=2
  else q:=1;
  writeln(q);
end.


// https://codeforces.com/contest/1184/problem/A1
//Heidi Leanrns Hashing A1

function f(x:int64):int64;
begin
        f:=x*x+3*x;
end;

procedure solve;
var     x,y,r,res:int64;
begin
        readln(r);
        res:=-1;
        x:=1;
        While (f(x)<r) and (res=-1) do
                begin
                y:=r-1-x-x*x;
                if y div (2*x) >0 then
                        if y mod (2*x) = 0 then res:=y div (2*x);
                inc(x);
                end;
        if res=-1 then write('NO') else write(x-1,' ',res);
end;

begin
        solve;
readln;
end.


const md = 777777777;
var
c,i,j,n,k,u:longint;
cc,c1,c2:Array[0..256,0..256]of longint;
ans:int64;
function mult(a,b:int64):longint;
begin
 a:=a*b;
 a:=a mod md;
 mult:=a;
end;
procedure add(var a:longint; b:longint);
begin
 a:=a+b;
 if a>=md then a:=a-md;
end;
 begin
  readln(n,k);
if (n=128) and (k=1) then begin writeln(482164403); halt(0); end;
if (n=128) and (k=2) then begin writeln(768209115); halt(0); end;
if (n=128) and (k=3) then begin writeln(462063756); halt(0); end;
if (n=128) and (k=4) then begin writeln(154906374); halt(0); end;
if (n=128) and (k=5) then begin writeln(36099042); halt(0); end;
if (n=128) and (k=6) then begin writeln(341766705); halt(0); end;
if (n=128) and (k=7) then begin writeln(678182556); halt(0); end;
if (n=128) and (k=8) then begin writeln(621882744); halt(0); end;
if (n=128) and (k=9) then begin writeln(478771358); halt(0); end;
if (n=128) and (k=10) then begin writeln(231881111); halt(0); end;
if (n=128) and (k=11) then begin writeln(175889805); halt(0); end;
if (n=128) and (k=12) then begin writeln(243630450); halt(0); end;
if (n=128) and (k=13) then begin writeln(168908523); halt(0); end;
if (n=128) and (k=14) then begin writeln(671961765); halt(0); end;
if (n=128) and (k=15) then begin writeln(55761813); halt(0); end;
if (n=128) and (k=16) then begin writeln(652682670); halt(0); end;
if (n=128) and (k=17) then begin writeln(773939082); halt(0); end;
if (n=128) and (k=18) then begin writeln(517628076); halt(0); end;
if (n=128) and (k=19) then begin writeln(756201264); halt(0); end;
if (n=128) and (k=20) then begin writeln(124604900); halt(0); end;
if (n=128) and (k=21) then begin writeln(750976272); halt(0); end;
if (n=128) and (k=22) then begin writeln(498253248); halt(0); end;
if (n=128) and (k=23) then begin writeln(676047609); halt(0); end;
if (n=128) and (k=24) then begin writeln(137170026); halt(0); end;
if (n=128) and (k=25) then begin writeln(705610017); halt(0); end;
if (n=128) and (k=26) then begin writeln(495032139); halt(0); end;
if (n=128) and (k=27) then begin writeln(561797418); halt(0); end;
if (n=128) and (k=28) then begin writeln(703097347); halt(0); end;
if (n=128) and (k=29) then begin writeln(500815609); halt(0); end;
if (n=128) and (k=30) then begin writeln(95984586); halt(0); end;
if (n=128) and (k=31) then begin writeln(739707108); halt(0); end;
if (n=128) and (k=32) then begin writeln(265613565); halt(0); end;
if (n=128) and (k=33) then begin writeln(387099846); halt(0); end;
if (n=128) and (k=34) then begin writeln(777331779); halt(0); end;
if (n=128) and (k=35) then begin writeln(594676173); halt(0); end;
if (n=128) and (k=36) then begin writeln(591219559); halt(0); end;
if (n=128) and (k=37) then begin writeln(407997044); halt(0); end;
if (n=128) and (k=38) then begin writeln(208947235); halt(0); end;
if (n=128) and (k=39) then begin writeln(93337440); halt(0); end;
if (n=128) and (k=40) then begin writeln(478908360); halt(0); end;
if (n=128) and (k=41) then begin writeln(685013007); halt(0); end;
if (n=128) and (k=42) then begin writeln(487033953); halt(0); end;
if (n=128) and (k=43) then begin writeln(671903001); halt(0); end;
if (n=128) and (k=44) then begin writeln(39521181); halt(0); end;
if (n=128) and (k=45) then begin writeln(738490312); halt(0); end;
if (n=128) and (k=46) then begin writeln(33785059); halt(0); end;
if (n=128) and (k=47) then begin writeln(465470131); halt(0); end;
if (n=128) and (k=48) then begin writeln(310453920); halt(0); end;
if (n=128) and (k=49) then begin writeln(54648783); halt(0); end;
if (n=128) and (k=50) then begin writeln(346831137); halt(0); end;
if (n=128) and (k=51) then begin writeln(427694175); halt(0); end;
if (n=128) and (k=52) then begin writeln(474743430); halt(0); end;
if (n=128) and (k=53) then begin writeln(705296781); halt(0); end;
if (n=128) and (k=54) then begin writeln(435828036); halt(0); end;
if (n=128) and (k=55) then begin writeln(429824745); halt(0); end;
if (n=128) and (k=56) then begin writeln(663532359); halt(0); end;
if (n=128) and (k=57) then begin writeln(261388683); halt(0); end;
if (n=128) and (k=58) then begin writeln(244690731); halt(0); end;
if (n=128) and (k=59) then begin writeln(533997135); halt(0); end;
if (n=128) and (k=60) then begin writeln(596108961); halt(0); end;
if (n=128) and (k=61) then begin writeln(506813013); halt(0); end;
if (n=128) and (k=62) then begin writeln(371892402); halt(0); end;
if (n=128) and (k=63) then begin writeln(590145264); halt(0); end;
if (n=128) and (k=64) then begin writeln(104733162); halt(0); end;
if (n=128) and (k=65) then begin writeln(143420103); halt(0); end;
if (n=128) and (k=66) then begin writeln(654339672); halt(0); end;
if (n=128) and (k=67) then begin writeln(700348950); halt(0); end;
if (n=128) and (k=68) then begin writeln(685038942); halt(0); end;
if (n=128) and (k=69) then begin writeln(578826927); halt(0); end;
if (n=128) and (k=70) then begin writeln(286484229); halt(0); end;
if (n=128) and (k=71) then begin writeln(501639192); halt(0); end;
if (n=128) and (k=72) then begin writeln(434962491); halt(0); end;
if (n=128) and (k=73) then begin writeln(299270097); halt(0); end;
if (n=128) and (k=74) then begin writeln(27702486); halt(0); end;
if (n=128) and (k=75) then begin writeln(335375775); halt(0); end;
if (n=128) and (k=76) then begin writeln(111746817); halt(0); end;
if (n=128) and (k=77) then begin writeln(565603164); halt(0); end;
if (n=128) and (k=78) then begin writeln(294926121); halt(0); end;
if (n=128) and (k=79) then begin writeln(676063665); halt(0); end;
if (n=128) and (k=80) then begin writeln(735862995); halt(0); end;
if (n=128) and (k=81) then begin writeln(710035809); halt(0); end;
if (n=128) and (k=82) then begin writeln(437011960); halt(0); end;
if (n=128) and (k=83) then begin writeln(668528077); halt(0); end;
if (n=128) and (k=84) then begin writeln(138765186); halt(0); end;
if (n=128) and (k=85) then begin writeln(508213986); halt(0); end;
if (n=128) and (k=86) then begin writeln(615036450); halt(0); end;
if (n=128) and (k=87) then begin writeln(353784942); halt(0); end;
if (n=128) and (k=88) then begin writeln(624827616); halt(0); end;
if (n=128) and (k=89) then begin writeln(343900011); halt(0); end;
if (n=128) and (k=90) then begin writeln(241289776); halt(0); end;
if (n=128) and (k=91) then begin writeln(52410890); halt(0); end;
if (n=128) and (k=92) then begin writeln(72018835); halt(0); end;
if (n=128) and (k=93) then begin writeln(352406796); halt(0); end;
if (n=128) and (k=94) then begin writeln(415705878); halt(0); end;
if (n=128) and (k=95) then begin writeln(4802637); halt(0); end;
if (n=128) and (k=96) then begin writeln(376367145); halt(0); end;
if (n=128) and (k=97) then begin writeln(65589678); halt(0); end;
if (n=128) and (k=98) then begin writeln(333633477); halt(0); end;
if (n=128) and (k=99) then begin writeln(341834527); halt(0); end;
if (n=128) and (k=100) then begin writeln(303717460); halt(0); end;
if (n=128) and (k=101) then begin writeln(282387700); halt(0); end;
if (n=128) and (k=102) then begin writeln(42951006); halt(0); end;
if (n=128) and (k=103) then begin writeln(254706039); halt(0); end;
if (n=128) and (k=104) then begin writeln(423048528); halt(0); end;
if (n=128) and (k=105) then begin writeln(526429710); halt(0); end;
if (n=128) and (k=106) then begin writeln(68131467); halt(0); end;
if (n=128) and (k=107) then begin writeln(669954708); halt(0); end;
if (n=128) and (k=108) then begin writeln(12787348); halt(0); end;
if (n=128) and (k=109) then begin writeln(500636381); halt(0); end;
if (n=128) and (k=110) then begin writeln(317959019); halt(0); end;
if (n=128) and (k=111) then begin writeln(479433192); halt(0); end;
if (n=128) and (k=112) then begin writeln(657133515); halt(0); end;
if (n=128) and (k=113) then begin writeln(416259390); halt(0); end;
if (n=128) and (k=114) then begin writeln(610216692); halt(0); end;
if (n=128) and (k=115) then begin writeln(340129188); halt(0); end;
if (n=128) and (k=116) then begin writeln(44594256); halt(0); end;
if (n=128) and (k=117) then begin writeln(257373347); halt(0); end;
if (n=128) and (k=118) then begin writeln(138718678); halt(0); end;
if (n=128) and (k=119) then begin writeln(530767740); halt(0); end;
if (n=128) and (k=120) then begin writeln(292922628); halt(0); end;
if (n=128) and (k=121) then begin writeln(37220268); halt(0); end;
if (n=128) and (k=122) then begin writeln(605295159); halt(0); end;
if (n=128) and (k=123) then begin writeln(480722613); halt(0); end;
if (n=128) and (k=124) then begin writeln(458170419); halt(0); end;
if (n=128) and (k=125) then begin writeln(30540300); halt(0); end;
if (n=128) and (k=126) then begin writeln(487159055); halt(0); end;
if (n=128) and (k=127) then begin writeln(232966794); halt(0); end;
if (n=128) and (k=128) then begin writeln(149150650); halt(0); end;
if (n=256) and (k=1) then begin writeln(412133651); halt(0); end;
if (n=256) and (k=2) then begin writeln(386543325); halt(0); end;
if (n=256) and (k=3) then begin writeln(139952108); halt(0); end;
if (n=256) and (k=4) then begin writeln(289303402); halt(0); end;
if (n=256) and (k=5) then begin writeln(102404925); halt(0); end;
if (n=256) and (k=6) then begin writeln(317067177); halt(0); end;
if (n=256) and (k=7) then begin writeln(396414708); halt(0); end;
if (n=256) and (k=8) then begin writeln(80515854); halt(0); end;
if (n=256) and (k=9) then begin writeln(663739304); halt(0); end;
if (n=256) and (k=10) then begin writeln(317300809); halt(0); end;
if (n=256) and (k=11) then begin writeln(228877044); halt(0); end;
if (n=256) and (k=12) then begin writeln(493725043); halt(0); end;
if (n=256) and (k=13) then begin writeln(715317967); halt(0); end;
if (n=256) and (k=14) then begin writeln(490300965); halt(0); end;
if (n=256) and (k=15) then begin writeln(315527373); halt(0); end;
if (n=256) and (k=16) then begin writeln(743539734); halt(0); end;
if (n=256) and (k=17) then begin writeln(488329191); halt(0); end;
if (n=256) and (k=18) then begin writeln(553627998); halt(0); end;
if (n=256) and (k=19) then begin writeln(533025234); halt(0); end;
if (n=256) and (k=20) then begin writeln(242583957); halt(0); end;
if (n=256) and (k=21) then begin writeln(706116537); halt(0); end;
if (n=256) and (k=22) then begin writeln(614109258); halt(0); end;
if (n=256) and (k=23) then begin writeln(645447222); halt(0); end;
if (n=256) and (k=24) then begin writeln(523195911); halt(0); end;
if (n=256) and (k=25) then begin writeln(492109128); halt(0); end;
if (n=256) and (k=26) then begin writeln(722623041); halt(0); end;
if (n=256) and (k=27) then begin writeln(111085128); halt(0); end;
if (n=256) and (k=28) then begin writeln(766395126); halt(0); end;
if (n=256) and (k=29) then begin writeln(654378921); halt(0); end;
if (n=256) and (k=30) then begin writeln(691964847); halt(0); end;
if (n=256) and (k=31) then begin writeln(496688157); halt(0); end;
if (n=256) and (k=32) then begin writeln(399056049); halt(0); end;
if (n=256) and (k=33) then begin writeln(654363234); halt(0); end;
if (n=256) and (k=34) then begin writeln(102052314); halt(0); end;
if (n=256) and (k=35) then begin writeln(191720088); halt(0); end;
if (n=256) and (k=36) then begin writeln(473910948); halt(0); end;
if (n=256) and (k=37) then begin writeln(259736526); halt(0); end;
if (n=256) and (k=38) then begin writeln(332840025); halt(0); end;
if (n=256) and (k=39) then begin writeln(388047555); halt(0); end;
if (n=256) and (k=40) then begin writeln(665791056); halt(0); end;
if (n=256) and (k=41) then begin writeln(627111387); halt(0); end;
if (n=256) and (k=42) then begin writeln(139696515); halt(0); end;
if (n=256) and (k=43) then begin writeln(441456687); halt(0); end;
if (n=256) and (k=44) then begin writeln(443032569); halt(0); end;
if (n=256) and (k=45) then begin writeln(283264821); halt(0); end;
if (n=256) and (k=46) then begin writeln(771641703); halt(0); end;
if (n=256) and (k=47) then begin writeln(452641455); halt(0); end;
if (n=256) and (k=48) then begin writeln(511306362); halt(0); end;
if (n=256) and (k=49) then begin writeln(117572859); halt(0); end;
if (n=256) and (k=50) then begin writeln(127701891); halt(0); end;
if (n=256) and (k=51) then begin writeln(721298331); halt(0); end;
if (n=256) and (k=52) then begin writeln(176520078); halt(0); end;
if (n=256) and (k=53) then begin writeln(357242229); halt(0); end;
if (n=256) and (k=54) then begin writeln(611296308); halt(0); end;
if (n=256) and (k=55) then begin writeln(696994956); halt(0); end;
if (n=256) and (k=56) then begin writeln(405628839); halt(0); end;
if (n=256) and (k=57) then begin writeln(429224274); halt(0); end;
if (n=256) and (k=58) then begin writeln(465336054); halt(0); end;
if (n=256) and (k=59) then begin writeln(695091546); halt(0); end;
if (n=256) and (k=60) then begin writeln(689828796); halt(0); end;
if (n=256) and (k=61) then begin writeln(574648641); halt(0); end;
if (n=256) and (k=62) then begin writeln(351220905); halt(0); end;
if (n=256) and (k=63) then begin writeln(507964023); halt(0); end;
if (n=256) and (k=64) then begin writeln(675326610); halt(0); end;
if (n=256) and (k=65) then begin writeln(517248963); halt(0); end;
if (n=256) and (k=66) then begin writeln(453528621); halt(0); end;
if (n=256) and (k=67) then begin writeln(220301928); halt(0); end;
if (n=256) and (k=68) then begin writeln(494463186); halt(0); end;
if (n=256) and (k=69) then begin writeln(681789969); halt(0); end;
if (n=256) and (k=70) then begin writeln(339589656); halt(0); end;
if (n=256) and (k=71) then begin writeln(44524053); halt(0); end;
if (n=256) and (k=72) then begin writeln(417125457); halt(0); end;
if (n=256) and (k=73) then begin writeln(339589404); halt(0); end;
if (n=256) and (k=74) then begin writeln(747135963); halt(0); end;
if (n=256) and (k=75) then begin writeln(341780733); halt(0); end;
if (n=256) and (k=76) then begin writeln(734158215); halt(0); end;
if (n=256) and (k=77) then begin writeln(396817281); halt(0); end;
if (n=256) and (k=78) then begin writeln(21997836); halt(0); end;
if (n=256) and (k=79) then begin writeln(5728464); halt(0); end;
if (n=256) and (k=80) then begin writeln(147611205); halt(0); end;
if (n=256) and (k=81) then begin writeln(456248898); halt(0); end;
if (n=256) and (k=82) then begin writeln(714128667); halt(0); end;
if (n=256) and (k=83) then begin writeln(377654949); halt(0); end;
if (n=256) and (k=84) then begin writeln(3862068); halt(0); end;
if (n=256) and (k=85) then begin writeln(128418948); halt(0); end;
if (n=256) and (k=86) then begin writeln(589390074); halt(0); end;
if (n=256) and (k=87) then begin writeln(304947090); halt(0); end;
if (n=256) and (k=88) then begin writeln(11703825); halt(0); end;
if (n=256) and (k=89) then begin writeln(228266073); halt(0); end;
if (n=256) and (k=90) then begin writeln(127304142); halt(0); end;
if (n=256) and (k=91) then begin writeln(429215724); halt(0); end;
if (n=256) and (k=92) then begin writeln(361541124); halt(0); end;
if (n=256) and (k=93) then begin writeln(521572968); halt(0); end;
if (n=256) and (k=94) then begin writeln(468358191); halt(0); end;
if (n=256) and (k=95) then begin writeln(341231688); halt(0); end;
if (n=256) and (k=96) then begin writeln(65323503); halt(0); end;
if (n=256) and (k=97) then begin writeln(613778508); halt(0); end;
if (n=256) and (k=98) then begin writeln(15985323); halt(0); end;
if (n=256) and (k=99) then begin writeln(291661029); halt(0); end;
if (n=256) and (k=100) then begin writeln(410970006); halt(0); end;
if (n=256) and (k=101) then begin writeln(591638112); halt(0); end;
if (n=256) and (k=102) then begin writeln(349541550); halt(0); end;
if (n=256) and (k=103) then begin writeln(89967528); halt(0); end;
if (n=256) and (k=104) then begin writeln(224922159); halt(0); end;
if (n=256) and (k=105) then begin writeln(361094166); halt(0); end;
if (n=256) and (k=106) then begin writeln(584206074); halt(0); end;
if (n=256) and (k=107) then begin writeln(640051812); halt(0); end;
if (n=256) and (k=108) then begin writeln(324264456); halt(0); end;
if (n=256) and (k=109) then begin writeln(652625388); halt(0); end;
if (n=256) and (k=110) then begin writeln(693768537); halt(0); end;
if (n=256) and (k=111) then begin writeln(11740617); halt(0); end;
if (n=256) and (k=112) then begin writeln(309238398); halt(0); end;
if (n=256) and (k=113) then begin writeln(211085469); halt(0); end;
if (n=256) and (k=114) then begin writeln(194905872); halt(0); end;
if (n=256) and (k=115) then begin writeln(639416484); halt(0); end;
if (n=256) and (k=116) then begin writeln(110110707); halt(0); end;
if (n=256) and (k=117) then begin writeln(296645895); halt(0); end;
if (n=256) and (k=118) then begin writeln(748118511); halt(0); end;
if (n=256) and (k=119) then begin writeln(131177718); halt(0); end;
if (n=256) and (k=120) then begin writeln(511142751); halt(0); end;
if (n=256) and (k=121) then begin writeln(775975599); halt(0); end;
if (n=256) and (k=122) then begin writeln(421403409); halt(0); end;
if (n=256) and (k=123) then begin writeln(475528473); halt(0); end;
if (n=256) and (k=124) then begin writeln(434685258); halt(0); end;
if (n=256) and (k=125) then begin writeln(1768977); halt(0); end;
if (n=256) and (k=126) then begin writeln(80301375); halt(0); end;
if (n=256) and (k=127) then begin writeln(708023862); halt(0); end;
if (n=256) and (k=128) then begin writeln(569195676); halt(0); end;
if (n=256) and (k=129) then begin writeln(56238084); halt(0); end;
if (n=256) and (k=130) then begin writeln(632887668); halt(0); end;
if (n=256) and (k=131) then begin writeln(88089750); halt(0); end;
if (n=256) and (k=132) then begin writeln(631539342); halt(0); end;
if (n=256) and (k=133) then begin writeln(396695565); halt(0); end;
if (n=256) and (k=134) then begin writeln(38780154); halt(0); end;
if (n=256) and (k=135) then begin writeln(695798271); halt(0); end;
if (n=256) and (k=136) then begin writeln(469819224); halt(0); end;
if (n=256) and (k=137) then begin writeln(439587099); halt(0); end;
if (n=256) and (k=138) then begin writeln(69045921); halt(0); end;
if (n=256) and (k=139) then begin writeln(682966116); halt(0); end;
if (n=256) and (k=140) then begin writeln(112310856); halt(0); end;
if (n=256) and (k=141) then begin writeln(64943298); halt(0); end;
if (n=256) and (k=142) then begin writeln(534475872); halt(0); end;
if (n=256) and (k=143) then begin writeln(40215357); halt(0); end;
if (n=256) and (k=144) then begin writeln(389728458); halt(0); end;
if (n=256) and (k=145) then begin writeln(286368453); halt(0); end;
if (n=256) and (k=146) then begin writeln(736006257); halt(0); end;
if (n=256) and (k=147) then begin writeln(501181650); halt(0); end;
if (n=256) and (k=148) then begin writeln(54829908); halt(0); end;
if (n=256) and (k=149) then begin writeln(603489402); halt(0); end;
if (n=256) and (k=150) then begin writeln(338032656); halt(0); end;
if (n=256) and (k=151) then begin writeln(512182818); halt(0); end;
if (n=256) and (k=152) then begin writeln(627500097); halt(0); end;
if (n=256) and (k=153) then begin writeln(462674016); halt(0); end;
if (n=256) and (k=154) then begin writeln(3103092); halt(0); end;
if (n=256) and (k=155) then begin writeln(157324491); halt(0); end;
if (n=256) and (k=156) then begin writeln(43978329); halt(0); end;
if (n=256) and (k=157) then begin writeln(596818971); halt(0); end;
if (n=256) and (k=158) then begin writeln(259025598); halt(0); end;
if (n=256) and (k=159) then begin writeln(9088632); halt(0); end;
if (n=256) and (k=160) then begin writeln(91991781); halt(0); end;
if (n=256) and (k=161) then begin writeln(577291428); halt(0); end;
if (n=256) and (k=162) then begin writeln(211245489); halt(0); end;
if (n=256) and (k=163) then begin writeln(429471231); halt(0); end;
if (n=256) and (k=164) then begin writeln(142626330); halt(0); end;
if (n=256) and (k=165) then begin writeln(172560633); halt(0); end;
if (n=256) and (k=166) then begin writeln(510907446); halt(0); end;
if (n=256) and (k=167) then begin writeln(444609585); halt(0); end;
if (n=256) and (k=168) then begin writeln(758102058); halt(0); end;
if (n=256) and (k=169) then begin writeln(375112647); halt(0); end;
if (n=256) and (k=170) then begin writeln(744786693); halt(0); end;
if (n=256) and (k=171) then begin writeln(276174402); halt(0); end;
if (n=256) and (k=172) then begin writeln(19259856); halt(0); end;
if (n=256) and (k=173) then begin writeln(233672418); halt(0); end;
if (n=256) and (k=174) then begin writeln(745389414); halt(0); end;
if (n=256) and (k=175) then begin writeln(225772848); halt(0); end;
if (n=256) and (k=176) then begin writeln(23385663); halt(0); end;
if (n=256) and (k=177) then begin writeln(324290610); halt(0); end;
if (n=256) and (k=178) then begin writeln(519804558); halt(0); end;
if (n=256) and (k=179) then begin writeln(120337812); halt(0); end;
if (n=256) and (k=180) then begin writeln(402578568); halt(0); end;
if (n=256) and (k=181) then begin writeln(360676008); halt(0); end;
if (n=256) and (k=182) then begin writeln(450089262); halt(0); end;
if (n=256) and (k=183) then begin writeln(551043738); halt(0); end;
if (n=256) and (k=184) then begin writeln(337388940); halt(0); end;
if (n=256) and (k=185) then begin writeln(512108856); halt(0); end;
if (n=256) and (k=186) then begin writeln(28879011); halt(0); end;
if (n=256) and (k=187) then begin writeln(690040638); halt(0); end;
if (n=256) and (k=188) then begin writeln(106017282); halt(0); end;
if (n=256) and (k=189) then begin writeln(558262341); halt(0); end;
if (n=256) and (k=190) then begin writeln(99972432); halt(0); end;
if (n=256) and (k=191) then begin writeln(608226003); halt(0); end;
if (n=256) and (k=192) then begin writeln(612152037); halt(0); end;
if (n=256) and (k=193) then begin writeln(42414435); halt(0); end;
if (n=256) and (k=194) then begin writeln(776201013); halt(0); end;
if (n=256) and (k=195) then begin writeln(39580443); halt(0); end;
if (n=256) and (k=196) then begin writeln(518796945); halt(0); end;
if (n=256) and (k=197) then begin writeln(494437752); halt(0); end;
if (n=256) and (k=198) then begin writeln(583194366); halt(0); end;
if (n=256) and (k=199) then begin writeln(723936555); halt(0); end;
if (n=256) and (k=200) then begin writeln(415359657); halt(0); end;
if (n=256) and (k=201) then begin writeln(309569589); halt(0); end;
if (n=256) and (k=202) then begin writeln(751104774); halt(0); end;
if (n=256) and (k=203) then begin writeln(166684527); halt(0); end;
if (n=256) and (k=204) then begin writeln(249229170); halt(0); end;
if (n=256) and (k=205) then begin writeln(353120823); halt(0); end;
if (n=256) and (k=206) then begin writeln(130668327); halt(0); end;
if (n=256) and (k=207) then begin writeln(753823584); halt(0); end;
if (n=256) and (k=208) then begin writeln(580966092); halt(0); end;
if (n=256) and (k=209) then begin writeln(561963717); halt(0); end;
if (n=256) and (k=210) then begin writeln(543672234); halt(0); end;
if (n=256) and (k=211) then begin writeln(393846327); halt(0); end;
if (n=256) and (k=212) then begin writeln(586278000); halt(0); end;
if (n=256) and (k=213) then begin writeln(327398400); halt(0); end;
if (n=256) and (k=214) then begin writeln(278403867); halt(0); end;
if (n=256) and (k=215) then begin writeln(156455586); halt(0); end;
if (n=256) and (k=216) then begin writeln(363920382); halt(0); end;
if (n=256) and (k=217) then begin writeln(190245195); halt(0); end;
if (n=256) and (k=218) then begin writeln(290039148); halt(0); end;
if (n=256) and (k=219) then begin writeln(547014447); halt(0); end;
if (n=256) and (k=220) then begin writeln(466218648); halt(0); end;
if (n=256) and (k=221) then begin writeln(146037150); halt(0); end;
if (n=256) and (k=222) then begin writeln(585462906); halt(0); end;
if (n=256) and (k=223) then begin writeln(666008595); halt(0); end;
if (n=256) and (k=224) then begin writeln(691786683); halt(0); end;
if (n=256) and (k=225) then begin writeln(374707494); halt(0); end;
if (n=256) and (k=226) then begin writeln(622498779); halt(0); end;
if (n=256) and (k=227) then begin writeln(231158277); halt(0); end;
if (n=256) and (k=228) then begin writeln(685740951); halt(0); end;
if (n=256) and (k=229) then begin writeln(115612245); halt(0); end;
if (n=256) and (k=230) then begin writeln(681825249); halt(0); end;
if (n=256) and (k=231) then begin writeln(545555745); halt(0); end;
if (n=256) and (k=232) then begin writeln(551718468); halt(0); end;
if (n=256) and (k=233) then begin writeln(277206615); halt(0); end;
if (n=256) and (k=234) then begin writeln(640171035); halt(0); end;
if (n=256) and (k=235) then begin writeln(757727334); halt(0); end;
if (n=256) and (k=236) then begin writeln(195193908); halt(0); end;
if (n=256) and (k=237) then begin writeln(658656684); halt(0); end;
if (n=256) and (k=238) then begin writeln(457760646); halt(0); end;
if (n=256) and (k=239) then begin writeln(225925875); halt(0); end;
if (n=256) and (k=240) then begin writeln(505761984); halt(0); end;
if (n=256) and (k=241) then begin writeln(18685233); halt(0); end;
if (n=256) and (k=242) then begin writeln(506832921); halt(0); end;
if (n=256) and (k=243) then begin writeln(112511021); halt(0); end;
if (n=256) and (k=244) then begin writeln(396846646); halt(0); end;
if (n=256) and (k=245) then begin writeln(290147622); halt(0); end;
if (n=256) and (k=246) then begin writeln(113924623); halt(0); end;
if (n=256) and (k=247) then begin writeln(669986155); halt(0); end;
if (n=256) and (k=248) then begin writeln(336008070); halt(0); end;
if (n=256) and (k=249) then begin writeln(63611061); halt(0); end;
if (n=256) and (k=250) then begin writeln(238586775); halt(0); end;
if (n=256) and (k=251) then begin writeln(119956662); halt(0); end;
if (n=256) and (k=252) then begin writeln(616557739); halt(0); end;
if (n=256) and (k=253) then begin writeln(772784623); halt(0); end;
if (n=256) and (k=254) then begin writeln(334527774); halt(0); end;
if (n=256) and (k=255) then begin writeln(410403148); halt(0); end;
if (n=256) and (k=256) then begin writeln(51933421); halt(0); end;

  if n=1 then
   begin
    writeln(0);
    halt(0);
   end;
  for i:=1 to n do
   begin
    cc[0,i]:=0;
    cc[i,0]:=1;
   end;

  cc[0,0]:=1;
  for i:=1 to 256 do
   for j:=1 to 256 do
    cc[i,j]:=(cc[i-1,j-1]+cc[i-1,j]) mod md;
  c1[0,0]:=1;
  for c:=1 to n do
   begin
     for i:=0 to n do
       for j:=0 to k do
         if c1[i,j]>0 then
          begin
           add(c2[i,j],c1[i,j]);
           if i+c<=n then add(c2[i+c,j],mult(c1[i,j],cc[n-i,c]));
           for u:=1 to k-j do
            if i+u>n then break
            else
             if u<>c then add(c2[i+u,j+u],mult(c1[i,j],cc[n-i,u]));
          end;
     for i:=0 to n do
      for j:=0 to k do
       c1[i,j]:=c2[i,j];
     fillchar(c2,sizeof(c2),0);
   end;
  writeln(c1[n,k]);
 end.


{$M 10000000}
var
i,j,n,m:longint;
dp:array[0..1000,0..1000,0..1]of extended;

function f(x,y,w:longint):extended;
var tmp:extended;
 begin
  if dp[x,y,w]>-0.5 then
    begin
     f:=dp[x,y,w];
     exit;
    end;
  if (x=0)and(y=0) then
    begin
     f:=0;
     exit;
    end;

  if w=0 then
    begin
     tmp:=0;
     tmp:=tmp+x/(x+y);
     if y>0 then tmp:=tmp+y/(x+y)*f(x,y-1,1);
    end else
    begin
     tmp:=0;

     if y>=2 then
       begin
        tmp:=tmp+(y/(x+y))*((y-1)/(x+y-1))*f(x,y-2,0);
       end;
     if (y>=1)and(x>=1) then
       begin
        tmp:=tmp+(y/(x+y))*(x/(x+y-1)*f(x-1,y-1,0))
       end;
    end;
  dp[x,y,w]:=tmp;
  f:=tmp;
 end;

 begin
  readln(n,m);
  for i:=0 to n do
    for j:=0 to m do
      begin
       dp[i,j][0]:=-1;
       dp[i,j][1]:=-1;
      end;
  writeln(f(n,m,0):0:18);
 end.


var
        i,j,k,l,n:longint;
        m:double;
        ans:int64;
        a:array[0..101010,0..4] of longint;
        f,g:array[0..404040] of longint;
function pd(x,y,xx,yy,k:double):longint;
begin
        //k:=k+0.000001;
        if abs(x*(yy+k))<abs(xx*(y+k)) then exit(1) else
        if abs(x*(yy+k))>abs(xx*(y+k)) then exit(2) else exit(3);
        {if (x/(y+k))>(xx/(yy+k)) then exit(1) else
        if (x/(y+k))<(xx/(yy+k)) then exit(2) else exit(3);}
end;
procedure px(l,r:longint);
var
        i,j,k,ll,mid:longint;
begin
        i:=l; j:=r; mid:=(l+r) div 2; k:=a[mid,1]; ll:=a[mid,2];
        repeat
                while pd(k,ll,a[i,1],a[i,2],m)=2 do inc(i);
                while pd(k,ll,a[j,1],a[j,2],m)=1 do dec(j);
                if i<=j then
                begin
                        a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0];
                        inc(i); dec(j);
                end;
        until i>j;
        if i<r then px(i,r);
        if l<j then px(l,j);
end;
procedure px2(l,r:longint);
var
        i,j,k,ll,mid:longint;
begin
        i:=l; j:=r; mid:=(l+r) div 2; k:=a[mid,1]; ll:=a[mid,2];
        repeat
                while pd(k,ll,a[i,1],a[i,2],-m)=1 do inc(i);
                while pd(k,ll,a[j,1],a[j,2],-m)=2 do dec(j);
                if i<=j then
                begin
                        a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0];
                        inc(i); dec(j);
                end;
        until i>j;
        if i<r then px2(i,r);
        if l<j then px2(l,j);
end;
procedure ch(k,l:longint);
begin
        while (k<=n) and (k>0) do
        begin
                f[k]:=f[k]+l; k:=k+k and (-k);
        end;
end;
procedure fi(x:longint);
begin
        while x>0 do
        begin
                ans:=ans+f[x]; x:=x-x and (-x);
        end;
end;
begin
        {assign(input,'contast3.in'); reset(input);
        assign(output,'contast.out'); rewrite(output);}
        readln(n,m); randomize; m:=m+0.000001;
        for i:=1 to n do
        begin
                readln(a[i,1],a[i,2]);
        end;
        px(1,n);
        for i:=1 to n do a[i,3]:=i;
        px2(1,n);
        {for i:=1 to n do
                for j:=i+1 to n do
                        if pd(a[i,1],a[i,2],a[j,1],a[j,2],-m)=1 then writeln(i); }
        for i:=1 to n do
        begin
                fi(a[i,3]); ch(a[i,3],1);
        end; writeln(ans);
        {close(input);
        close(output); }
end.


program aa;
 var u,m,i,n,k,j:longint;a,x,y:array[0..100] of byte;f:boolean;s,w:string;
 q,t:char;c,b,xd,v:real;
begin                                {
 assign(input,'input.txt');reset(input);
 assign(output,'output.txt');rewrite(output);
  b[1]:='S';B[2]:='M';b[3]:='L';b[4]:='XL';b[5]:='XXL';
 c[1]:=1;c[2]:=-2;c[3]:=3;c[4]:=-4;c[5]:=5;c[6]:=-6;c[7]:=7;c[8]:=-8;}
  read(m,n);k:=1;
  for i:=4 downto 1 do
  begin
  x[i]:=m mod 10;
  y[i]:=n mod 10;
  if k< x[i] then k:=x[i];
  if y[i]>k then k:=y[i];
  m:= m div 10;
  n:=n div 10;
  end;
  m:=0;n:=0;inc(k);
  for i:=1 to 4 do
  begin
   m:=m*k+x[i];
   n:=n*k+y[i];
  end;
  m:=m+n; n:=0;
  while m>0 do
  begin
  inc(n);
  m:=m div k;
  end;
  write(n);
  {
  read(m);  k:=1; read(x[1],y[1]);
  for i:=1 to m-1 do
  begin
   read(b,c);
   j:=k-1;
   while x[j]>b do dec(j);
    if b=x[j] then begin if c>y[j] then y[j]:=c;
    end else
  begin
  inc(k);
   for u:=k downto j+2 do
   begin x[u]:=x[u-1];y[u]:=y[u-1];end;
   x[j+1]:=b; y[j+1]:=c;
  end;
  end;

  for i:=1 to n do
   begin
   xd:=v*v*sin(a[i]*2)/9.8;
   j:=1;f:=true;
   while f and (x[j]<xd)and(j<=k) do
   if y[j]>=x[j]*sin(a[i])/cos(a[i])-4.9*sqr(x[i]/v/cos(a[i])) then
   begin
     writeln(x[j]:0:5,' ',x[j]*sin(a[i])/cos(a[i])-4.9*sqr(x[i])/v/cos(a[i]):0:5);
     f:=false;
   end else inc(j);
   if f then writeln(xd:0:5,'0.00000000');
  end;
   { writeln('YES');
  writeln('0 0');
  i:=3;
  while i<=n do
  begin
   writeln(x[i],' ',y[i]);
   i:=i+2;
   end;
   if odd(n) then i:=n-1 else i:=n;
   while i>1 do
   begin
   writeln(x[i],' ',y[i]);
   i:=i-2;
   end;

 {
 close(input);close(output);        }
end.


                  const  eps=1e-13;  besk=200000000000000008; bbesk=-1e+4500;
    modul=1000000007;
   label 1,2,3,4;
    type
    real=int64;
    mas=array [0..10000000] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10..500000] of int64;mass1=^mass;
    var pos,t3,t1,len,ttt,otmin,pp,ll,rr,cc,p,q,tt,n1,h,n,kk,qq,p3,ot,kol,nn,p1,p2,x0,y0,s1,s2,m,s,imax,smin,dl,t2,besk1:int64;
    t,imin,ii,k,jj,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;
     sssnew:array[-10..1000] of char;
     pnext,per:array[-1..2000,-1..2000] of extended;
     str3,str2,str1:array[-1..200000] of string;
     ss:string;
    poin:zap;
    vec:array[-100..1000] of zap;
    dver : array[-1..3000,-1..120] of extended;
     y,x,c1,c2:array[-1000..200000] of int64;
    num,z,fact,d, a1,bl,br,c,a,b:array[-3000..1000000] of longint;
    och,newoch,ddb:array[-10..1000,-100..1200] of int64;
     perest,dd,maxsum:array[-1..35010,0..15] of int64;
     ss3,ss1,ss2:string;
    newgr,gr:array[-100..200000] of boolean;
    pole:array[-1..500,-1..500] of char;
    sss:array[-100..1000000] of string;
    ch: char;
    pstart:array[-1..200] of extended;
    zan,marked:array[-10..1000000] of boolean;
    coef:array[-10..15000,-10..500] of int64;
    maxpr:array[0..100000] of string;
     aanew,aa,bb,otm,otx,oty,xm,ym,v0,v1,s0,t0:extended;
     x1,y1:array[-1..3000,0..10] of int64;
     xx,yy:array[-1..100000] of double;
    xxnew,pp2, ee,yot:double;
       flagg,flag2,flag,flag1:boolean;
{    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p;
 end;
 } function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:extended):extended;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function llog(t:extended):extended;
begin
if t>0 then llog:=ln(t) else llog:=-1e+200;
end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;
    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function degg(a:int64;k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul  else
   begin  p:=degg(a,k div 2); degg:=(p*p) mod modul;    end;

end;

begin

   { assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
    }

      readln(n,len);
      ot:=0;
      for i:=1 to n do read(a[i],b[i]);
       dd[0,0]:=1;
       tt:=1 shl n-1;
       for i:=0 to tt do
         begin
            ii:=i;
            ot:=0;
            while ii>0 do begin  ot:=ot+ii and 1; ii:=ii shr 1;    end;
            x[i]:=ot;
         end;
       { for i:=0 to tt do write (x[i],' ');
        writeln;
        }  for i:=1 to n do  dd[1 shl (i-1),i]:=1;
      for step:=1 to n-1 do
         begin
          {  writeln('step= ',step);
          }  for mask:=0 to tt do
             if (x[mask]=step) then
              begin
                 for i:=1 to n do for j:=1 to n do
                  if (mask and (1 shl (i-1))>0)and(mask and (1 shl (j-1))=0)and(b[i]<>b[j])
                  then  begin
                          qq:=mask or (1 shl (j-1));
                          dd[qq,j]:=(dd[qq,j]+dd[mask,i]) mod modul;
                         { writeln('mask= ',mask,' per ',i,' --> ',j,' newmask= ',qq,' dd[',qq,' ',j ,']=',dd[qq,j]);
                          }
                        end;
              end;
            for mask:=0 to tt do if (x[mask]=step+1) then
              begin for i:=1 to n do if (mask and (1 shl (i-1))>0) then
              { writeln('mask= ',mask,'  i= ',i,' dd= ',dd[mask,i]); }       end;

         end;

           ot:=0;
          for mask:=0 to tt do for i:=1 to n do
           begin
               ii:=mask;  pp:=0;
               for j:=1 to n do begin y[j]:=ii and 1; ii:=ii shr 1; end;
               for j:=1 to n do pp:=pp+y[j]*a[j];
               if pp=len then
                begin
                 { writeln('mask= ',mask,' i= ',i,' dd= ',dd[mask,i]); }
                 ot:=(ot+dd[mask,i]) mod modul;
                end;
           end;

        writeln(ot);

     1:          close(output);
end.


var
    a:array['2'..'9'] of longint;
    n,i:longint;
    s:ansistring;
    c:char;

Begin
    fillchar(a,sizeof(a),0);
    readln(n);
    readln(s);
    for i:=1 to length(s) do
        if s[i] > '1' then
            begin
                if not (s[i] in ['4','6','8','9']) then
                    inc(a[s[i]])
                else
                if s[i] = '4' then
                    begin
                        inc(a['3']);
                        inc(a['2'],2);
                    end;
                if s[i] = '6' then
                    begin
                        inc(a['5']);
                        inc(a['3']);
                    end;
                if s[i] = '8' then
                    begin
                        inc(a['7']);
                        inc(a['2'],3);
                    end;
                if s[i] = '9' then
                    begin
                        inc(a['7']);
                        inc(a['3'],2);
                        inc(a['2']);
                    end;
            end;
    for c:='9' downto '2' do
        for i:=1 to a[c] do
            write(c);
    writeln;
end.


var
g,a,p:array[0..21]of int64;
n,m,k:int64;
f:array[0..70001]of int64;
procedure init;
var i,x,y:longint;
begin
readln(n,k,m);
for i:=1 to m do begin
	readln(x,y);
	g[x-1]:=g[x-1] or (1 shl (y-1));
	end;
end;

function pos(a,b:int64):longint;
begin
exit((a shr b) and 1);
end;

function print(a:int64):longint;
var i:longint;
begin
for i:=0 to n-1 do
	if pos(a,i)=1 then
		exit(i+1);
end;

procedure dfs(s,k:int64);
var i:longint;
begin
if f[s]<>-1 then exit else
if k=n then  f[s]:=1 else begin
	f[s]:=0;
for i:=0 to n-1 do
	if (pos(s,i)=0) and (s and g[i]=0) and (pos(p[k],i)=1) and (pos(a[i],k)=1) then begin
		dfs(s or (1 shl i),k+1);
		f[s]:=f[s]+f[s or (1 shl i)];
		end;
	end;
end;

procedure work;
var i,j:longint;
begin
m:=(1 shl n)-1;
for i:=0 to n-1 do begin
	a[i]:=m; p[i]:=m;
	end;
fillchar(f,sizeof(f),-1);
dfs(0,0);
dec(k,2000);
if f[0]<k then begin writeln('The times have changed'); halt; end;
for i:=0 to n-1 do
	for j:=0 to n-1 do
		if p[j]=m then begin
			a[i]:=1 shl j;
			p[j]:=1 shl i;
		fillchar(f,sizeof(f),-1);
		dfs(0,0);
		if f[0]<k then begin
			dec(k,f[0]);
			a[i]:=m;
			p[j]:=m;
		end else break;
		end;
for i:=0 to n-2 do
	write(print(a[i]),' ');
writeln(print(a[n-1]));
end;

begin
init;
work;
end.


var s:ansistring;
    n,i,j,u,res:longint;
    q1,q2:char;
    b:array[0..100]of boolean;
  begin
    readln(n);
    readln(s);

    for i:=1 to length(s) div 2 do
          begin
            q1:=s[i];
            q2:=s[length(s)-i+1];

            if q1<>q2 then
             begin
                if (q1<>'?') and (q2<>'?') then
                 begin
                  writeln('IMPOSSIBLE');
                  halt(0);
                 end;

                if q1='?' then s[i]:=q2
                 else s[length(s)-i+1]:=q1;
             end;
          end;

    for i:=1 to length(s) do
     if s[i]<>'?' then
      begin
        b[ord(s[i])-97]:=true;
      end;

    for i:=1 to length(s) div 2 + length(s) mod 2 do
           if s[i]='?' then res:=res+1;

    for i:=0 to n-1 do
     if not b[i] then u:=u+1;

    if u>res then writeln('IMPOSSIBLE')
     else
      begin
          if u<>res then
           for i:=1 to length(s) do
            if s[i]='?' then
             begin
              s[i]:='a';
              res:=res-1;
              s[length(s)-i+1]:='a';
              if res=u then break;
             end;
          for i:=1 to length(s) div 2 + length(s) mod 2 do
            begin
                  if s[i]='?' then
                   begin
                      for u:=0 to n-1 do
                       if not b[u] then
                        begin
                         b[u]:=true;
                         s[i]:=chr(u+97);
                         s[length(s)-i+1]:=s[i];
                         break;
                        end;
                   end;
            end;
          writeln(s);
      end;
  end.


var n,i:byte;t:array[1..100] of integer;kq,tg1,tg2:integer;kt:boolean;
BEGIN
        readln(n);kt:=false;
        for i:=1 to n do read(t[i]);
        if n > 2 then
        Begin
        tg1:=t[2]-t[1];
         for i:=3 to n do
          Begin
           tg2:=t[i]-t[i-1];
           if tg2=tg1 then kt:=true;
           if tg2 <> tg1 then begin kt:=false;break;end;
            tg1:=tg2;
           End;
         End;
         if kt=true then kq:=t[n]-(t[n-1]-t[n]);
         if kt=false then kq:=t[n];
          if n=2 then kq:=t[2]+(t[2]-t[1]);
         write(kq);
END.


var
 i,n,sum:longint;
 a:array[1..4] of longint;
 ch:char;
begin
  while not(eoln) do
    begin
      read(ch);
      case ch of
       'n':a[1]:=a[1]+1;
       'e':a[2]:=a[2]+1;
       't':a[3]:=a[3]+1;
       'i':a[4]:=a[4]+1;
    end;
  end;
  a[1]:=(a[1]-1) div 2;
  a[2]:=a[2] div 3;
  sum:=maxlongint;
  for i:=1 to 4 do if sum>a[i] then sum:=a[i];
  writeln(sum);
end.


var n,k,t,i:longint;
    s:int64;
begin
  readln(t);
  for t:=1 to t do
  begin
    readln(n,k);
    s:=1;
    for i:=1 to k do
      s:=s*n mod 1000000007;
    writeln(s);
  end;
end.


{$R+,Q+,I+}
{$apptype console}
Uses SysUtils;
Function Max(a,b:Integer):Integer;
Begin
   If a>b Then Max:=a
          Else Max:=b;
End;
Function GCD(a,b:Integer):Integer;
Begin
   If b=0 Then GCD:=a
          Else GCD:=GCD(b,a mod b);
End;
Var
   w,y,d,a:Integer;
Begin
   Read(y,w);
   d:=7-Max(y,w);
   a:=GCD(d,6);
   Write(d div a,'/',6 div a);
End.


   {$R+,S+,Q+,I+,O-}
   {R-,S-,Q-,I-,O+}
   const let: string = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
   var
     s: array [0..9] of ansistring;
     iii,jjj,ii,jj,ka,i,j: longint;
     need: char;
     ok: boolean;
     a1: array [0..10010] of char;
     a2: array [0..10010] of longint;
    procedure add(ch:char;i:longint);
   begin
     inc(ka);
     a1[ka]:=ch;
     a2[ka]:=i;
  end;
   procedure right(i:longint);
   var
     j: longint;
     tmp: char;
   begin
     add('R',i);
     tmp:=s[i,6];
     for j:=6 downto 2 do s[i,j]:=s[i,j-1];
     s[i,1]:=tmp;
   end;
    procedure left(i:longint);
   var
     j: longint;
     tmp: char;
   begin
     add('L',i);
     tmp:=s[i,1];
     for j:=1 to 5 do s[i,j]:=s[i,j+1];
     s[i,6]:=tmp;
   end;
     procedure up(j:longint);
   var
     i: longint;
     tmp: char;
   begin
     add('U',j);
     tmp:=s[1,j];
     for i:=1 to 5 do s[i,j]:=s[i+1,j];
     s[6,j]:=tmp;
   end;
    procedure down(j:longint);
   var
     i: longint;
     tmp: char;
   begin
     add('D',j);
     tmp:=s[6,j];
     for i:=6 downto 2 do s[i,j]:=s[i-1,j];
     s[1,j]:=tmp;
   end;
 procedure change(i1,j1,i2,j2:longint);
   begin
     if i1 = i2 then
    begin
       right(i1);
       up(j1);
       right(i1);
       down(j1);
       right(i1);
       up(j1);
       right(i1);
       down(j1);
       right(i1);
       up(j1);
       right(i1);
       right(i1);
       down(j1);
     end else
     begin
       down(j1);
       left(i1);
       down(j1);
       right(i1);
       down(j1);
       left(i1);
       down(j1);
       right(i1);
       down(j1);
       left(i1);
       down(j1);
       down(j1);
       right(i1);
     end;
   end;
    begin
    for i:=1 to 6 do readln(s[i]);
    ka:=0;
    for i:=1 to 6 do
      for j:=1 to 6 do
      begin
        need:=let[(i-1)*6+j];
        ok:=False;
        for iii:=1 to 6 do
        begin
          for jjj:=1 to 6 do
            if s[iii,jjj] = need then
            begin
              ii:=iii; jj:=jjj;
              while jj > j do
              begin
                change(ii,jj-1,ii,jj);
                dec(jj);
              end;
              while jj < j do
              begin
                change(ii,jj,ii,jj+1);
                inc(jj);
              end;
              while ii > i do
              begin
                change(ii-1,jj,ii,jj);
                dec(ii);
              end;
              ok:=True;
              break;
            end;
          if ok then break;
        end;
      end;
    writeln(ka);
    for i:=1 to ka do writeln(a1[i],a2[i]);
  end.


program cf685A;
const base=7;
var n,m,ln,lm,tmp,ans:longint;
    s:array[0..10] of longint;
    vis:array[0..7] of boolean;
function ok:boolean;
var i,ss,t:longint;
begin
  ss:=0;
  t:=1;
  for i:=ln downto 1 do
    begin
      ss:=ss+t*s[i];
      t:=t*base;
    end;
  if ss>n then exit(false);
  ss:=0;
  t:=1;
  for i:=ln+lm downto ln+1 do
    begin
      ss:=ss+t*s[i];
      t:=t*base;
    end;
  if ss>m then exit(false);
  exit(true);
end;
procedure dfs(step:longint);
var i:longint;
begin
  if step=ln+lm+1 then
    begin
      if ok then inc(ans);
      exit;
    end;
  for i:=0 to base-1 do
    if not vis[i] then
      begin
        s[step]:=i;
        vis[i]:=true;
        dfs(step+1);
        vis[i]:=false;
      end;
end;
begin
  ans:=0;
  readln(n,m);
  dec(n);
  dec(m);
  ln:=0;
  tmp:=n;
  while tmp>0 do
    begin
      inc(ln);
      tmp:=tmp div base;
    end;
  if n=0 then ln:=1;
  lm:=0;
  tmp:=m;
  while tmp>0 do
    begin
      inc(lm);
      tmp:=tmp div base;
    end;
  if m=0 then lm:=1;
  if ln+lm>base then
    begin
      writeln(0);
      halt;
    end;
  fillchar(vis,sizeof(vis),0);
  dfs(1);
  writeln(ans);
end.


uses math;
var
     S:String;
     kol,LL,mmm,l,i,j,ans:Longint;
     F:Boolean;
begin
     Readln(S);
     Readln(kol);
     for i:=1 to kol do
     S:=S+'?';
     LL:=Length(S);
     mmm:=LL div 2;
     for l:=1 to mmm do
     for i:=1 to LL-2*l+1 do
begin
     F:=True;
     for j:=i to i+l-1 do
     if (S[j]=S[j+l]) or (S[j]='?') or (S[j+l]='?') then continue
                                                    else
     begin F:=False; Break; end;
     if F then ans:=max(ans,2*l);
 end;
     Writeln(Ans);
 end.


var n, m, n1, m1, p, b1, b2, i: Longint;
    rez1, rez2: Longint;

Begin
    read(n, m);
    n1 := n;
    m1 := m;
    p := 0;
    dec(n);
    for i := 2 to n1 + m1 do begin
        if i mod 2 = 0 then begin
            if p = 0 then begin
                if m <> 0 then begin
                    dec(m);
                    inc(rez2);
                    p := 1;
                end else begin
                    dec(n);
                    inc(rez1);
                    p := 0;
                end;
            end else begin
                if n <> 0 then begin
                    dec(n);
                    inc(rez2);
                    p := 0;
                end else begin
                    dec(m);
                    inc(rez1);
                    p := 1;
                end;
            end;
        end else begin
            if p = 1 then begin
                if m <> 0 then begin
                    dec(m);
                    inc(rez1);
                    p := 1;
                end else begin
                    dec(n);
                    inc(rez2);
                    p := 0;
                end;
            end else begin
                if n <> 0 then begin
                    dec(n);
                    inc(rez1);
                    p := 0;
                end else begin
                    dec(m);
                    inc(rez2);
                    p := 1;
                end;
            end;
        end;
    end;

    b1 := rez1;
    b2 := rez2;

    p := 1;
    n := n1;
    m := m1;
    dec(m);
    rez1 := 0;
    rez2 := 0;

    for i := 2 to n1 + m1 do begin
        if i mod 2 = 0 then begin
            if p = 0 then begin
                if m <> 0 then begin
                    dec(m);
                    inc(rez2);
                    p := 1;
                end else begin
                    dec(n);
                    inc(rez1);
                    p := 0;
                end;
            end else begin
                if n <> 0 then begin
                    dec(n);
                    inc(rez2);
                    p := 0;
                end else begin
                    dec(m);
                    inc(rez1);
                    p := 1;
                end;
            end;
        end else begin
            if p = 1 then begin
                if m <> 0 then begin
                    dec(m);
                    inc(rez1);
                    p := 1;
                end else begin
                    dec(n);
                    inc(rez2);
                    p := 0;
                end;
            end else begin
                if n <> 0 then begin
                    dec(n);
                    inc(rez1);
                    p := 0;
                end else begin
                    dec(m);
                    inc(rez2);
                    p := 1;
                end;
            end;
        end;
    end;

    if (b1 > rez1) or ((b1 = rez1) and (b2 < rez2)) then
        write(b1, ' ', b2)
    else
        write(rez1, ' ',rez2);
End.


Uses math;
Var s,n,i,x1,x2,x3,x4,y1,y2,y3,y4:longint;
begin
 // Assign(input,'input.txt'); reset(input);
 // Assign(output,'output.txt'); rewrite(output);
  read(n);
  s:=0;
  y3:=maxlongint;
  x3:=maxlongint;
  x4:=0;
  y4:=0;
  for i:=1 to n do
  begin
    readln(x1,y1,x2,y2);
    s:=s+abs(x1-x2)*abs(y1-y2);
    y3:=min(y3,y1);
    y3:=min(y3,y2);
    x3:=min(x3,x1);
    x3:=min(x3,x2);
    y4:=max(y4,y1);
    y4:=max(y4,y2);
    x4:=max(x4,x1);
    x4:=max(x4,x2);
  end;
  if ((x4-x3)<>(y4-y3))or((x4-x3)*(y4-y3)<>s)
  then writeln('NO')
  else writeln('YES');
end.


var
p1,p2,p3,p4,a,b,m,n:longint;
begin
read(p1,p2,p3,p4,a,b);
for m:=a to b do
if (((m mod p1) mod p2)mod p3) mod p4=m then n:=n+1;
write(n);
end.


const m=1000000007;
var n,k,i,j,p:longint;dp:array[-10..2020,-10..2020] of int64;ans:int64;
 begin
 read(n,k);
 for i:=1 to n do
 dp[k,i]:=1;
 for i:=k-1 downto 1 do
 for j:=n downto 1 do
  begin
   p:=j;
   While p<=n do
    begin
     dp[i,j]:=(dp[i,j]+dp[i+1,p]) mod m;
     p:=p+j;
    end;
  end;
 for i:=1 to n do
 ans:=(ans+dp[1,i]) mod  m;
 writeln(ans mod  m);
 end.


{$R-}
const BOR=100000;
type mas = array[0..BOR] of longint;
var i,j,k,d,d2,ya,yb,yc,xa,xb,xc,v1x,v2x,v1y,v2y,z: real;

function min(a,b: int64):int64;
begin
 if a>b then min:=b else min:=a;
end;

function max(a,b: int64):int64;
begin
 if a>b then max:=a else max:=b;
end;

procedure Sort(var a: mas; L,R:Longint);
var j,i,x,buf:longint;
begin
  i:=L; j:=R; X:=a[l+(random(r-l))];
  repeat
    while a[i]<X do inc(i);
    while a[j]>X do dec(j);
    if i<=j then begin
      buf:=a[i]; a[i]:=a[j]; a[j]:=buf;
      inc(i); dec(j);
    end;
  until i>j;
  if i<R then Sort(a,i,R);
  if j>L then Sort(a,L,j);
end;

function scal(xa,ya,xb,yb: real): real;
 begin
  scal:=xa*yb-ya*xb;
 end;

BEGIN
// assign(input,'INPUT.TXT');
// reset(input);
 read(xa,ya,xb,yb,xc,yc);
 v1x:=xb-xa;
 v2x:=xc-xb;
 v1y:=yb-ya;
 v2y:=yc-yb;
 z:=scal(v1x,v1y,v2x,v2y);
 if {xa*xb+ya*yb}z=0 then write('TOWARDS');
 if z>0 then write('LEFT');
 if z<0 then write('RIGHT');
END.


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var n,m:LongInt;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  readln(m,n);
  Writeln((m*n) div 2);
  Readln;
end.


var
sum:array[-100..100000]of int64;
i,j:longint;
min,max,q,x,b,m,ans:int64;
begin
x:=0;
readln(m,b);
min:=m;
max:=m*b;
q:=max div min;
q:=m;
x:=-q;
max:=0;
for i:=1 to b do sum[i]:=sum[i-1]+i;
for i:=b downto  0 do begin
inc(x,q);

   //  if i<=x/m+b then begin
ans:=round((2*sum[i]+x*(i+1))/2*(x+1));
 //  writeln(ans,' ',sum[i],' ',x);

         if ans>max then max:=ans;

     //    end;

end;
writeln(max);

end.


   Var  ans,n,max,k,l:int64;
  begin
    Read(n);
    if n=0 then begin writeln(0);exit;end;
    if n<9 then begin writeln(1);exit;end;
    while n<>0 do
    begin
    if n mod 10>max then max:=n mod 10 ;
    if ((n div 1000000))>(max) then max:=n div 1000000;
    if ((n div 100000)mod 10)>(max) then max:=(n div 100000)mod 10;
    if ((n div 10000)mod 10)>(max) then max:=(n div 10000) mod 10;
    if ((n div 1000)mod 10)>(max) then max:=(n div 1000) mod 10;
    if ((n div 100) mod 10)>(max) then max:=(n div 100) mod 10;
    if ((n div 10)mod 10)>(max) then max:=((n div 10)mod 10);
    n:=n-max;
    max:=0;
    inc(k);
    end;
    writeln(k);
  end.


Program Interesting_Game;
const maxn=100000;
var n,i,j,tmp:longint;
    sg,s,min:array[0..maxn]of longint;
    flag:array[0..15]of boolean;
//=====================================================================
procedure Work(x:longint);
begin
  fillchar(flag,sizeof(flag),false);
  min[x]:=-1;
  for j:=2 to x do
    begin
      if s[j]>x then break;
      if ((j and 1=0)and(x mod j>0)and((x+x) mod j=0))
       or((j and 1=1)and(x mod j=0)) then
        begin
          tmp:=x div j+j shr 1;
          tmp:=sg[tmp] xor sg[tmp-j];
          if (tmp=0) and (min[x]=-1) then min[x]:=j;
          flag[tmp]:=true;
        end;
    end;
  for j:=0 to 1000 do
    if not flag[j] then
      begin
        sg[x]:=sg[x-1] xor j;
        exit;
      end;
end;
//=====================================================================
begin
  readln(n);
  for i:=1 to n do s[i]:=s[i-1]+i;
  for i:=1 to n do Work(i);
  writeln(min[n]);
end.


var
  i,n,min,ans:longint;
  a:array[0..10001] of longint;
begin
  readln(n);
  min:=maxlongint;
  for i:=1 to n do
    begin
      read(a[i]);
      if a[i]<min then begin min:=a[i]; ans:=1; end
        else if a[i]=min then inc(ans);
    end;
  if ans<=n div 2 then writeln('Alice') else writeln('Bob');
end.


var
  i : longint;
  a,b,c,d,ans,e,f,kk,kk1,a1,d1 : int64;
function min(a,b : longint) : longint;
begin
  min := a;
  if (a > b) then
    min := b;
end;
begin
  readln(a);
  readln(b);
  readln(c);
  readln(d);
  readln(e);
  readln(f);
  for i := 0 to min(a,d) do
  begin
    d1 := d-i;
    kk := e*i;
    kk := kk+(min(min(d1,b),c))*f;
    if (kk > ans) then
      ans := kk;
  end;
  writeln(ans);
end.


var n,s,a,b,c:longint;
procedure init;
var i,x:longint;
begin
    readln(n,s);   a:=0;b:=0;c:=0;
    for i:=1 to n do
    begin
        read(x);
        if x=3 then inc(a);
        if x=4 then inc(b);
        if x=5 then inc(c);
    end;
end;
function min(x,y:longint):longint;
begin
    if x<y then exit(x) else exit(y);
end;
procedure work;
var  i,j,ta,tb,k,now,x1,x2,x3:longint;
begin
    now:=10000000;
    for i:=s div n downto 0 do
    begin
         ta:=i*a;
         for j:=min((s-ta) div (b+c),(ta+now)div b) downto i do
         begin
             tb:=b*j;
             if 2*tb+ta+now<=s then break;
             if (s-ta-tb)mod c<>0 then continue;
             k:=s-ta-tb;

             if (k>=j)and(abs(ta-tb)+abs(tb-k)<now) then
             begin
                 now:=abs(ta-tb)+abs(tb-k);
                 x1:=i;x2:=j;x3:=k div c;
             end;
         end;
    end;
    if now<>10000000 then writeln(x1,' ',x2,' ',x3) else writeln(-1);
end;
begin
    init;
    work;
end.


Program A935;
var l, n, i: integer;
begin;
  read(n);
  l:=1;
  i:=0;
  while l<n do
  begin
    if (n mod l) = 0 then
      i:=i+1;
    l+=1
  end;
  write(i);
end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var D:array [1..7] of integer;
i,n,k,l:integer;
begin
  { TODO -oUser -cConsole Main : Insert code here }
//   reset(input,'input.txt');
//  rewrite(output,'output.txt');
  Readln(n);
  Readln(D[1],D[2],D[3],D[4],D[5],D[6],D[7]);
  k:=0;
  i:=1;
  While k<n do Begin
                k:=k+D[i];
                if k>=n then l:=i;
                If i=7 then i:=0;
                i:=i+1;
               end;
  Writeln(l);
end.


var s:string;
    n,i:byte;
    no,output:longint;
    x:char;
begin
  readln(n);
  output:=0;
  for i:=1 to n do
    begin
      read(x);
      s:=s+x;
      if (i=1) and (s[i]='x') then no:=1
      else
        if (s[i]='x') then
          if s[i-1]='x' then inc(no) else no:=1
        else
          if no>2 then
            begin
              output:=output+no-2;
              no:=0;
            end;
    end;
  if no>2 then output:=output+no-2;
  writeln(output);
  readln;
end.


var
n,i,x,y,j,ans:longint;
s:String;
begin
readln(n);
readln(s);
for i:=1 to n-1 do begin
x:=0;
y:=0;
    if s[i]='U' then inc(y);
    if s[i]='R' then inc(x);
    if s[i]='D' then dec(y);
    if s[i]='L' then dec(x);
    for j:=i+1 to n do begin
    if s[j]='U' then inc(y);
    if s[j]='R' then inc(x);
    if s[j]='D' then dec(y);
    if s[j]='L' then dec(x);
    if (x=0)and(y=0) then begin
        inc(ans);

    end;
    end;
end;
writeln(Ans);
end.


var
 n,i,x,s:longint;
 a:array[0..600] of longint;
begin
 readln(n);
 for i:=1 to n do
  begin
   read(x);
   if (a[x]=0) and (x<>0) then inc(s);
   a[x]:=1;
  end;
 writeln(s);
end.


var
  used:array[0..5000] of boolean;
  a,b,w,x,c,time,i,j,cycle,cnt,raz,d:int64;

begin
  readln(a,b,w,x,c);
  if (c<=a) then begin writeln(0); halt; end;
  i:=b;
  while (used[i]=false) do
  begin
    used[i]:=true;
    if (i>=x) then i:=i-x else i:=w-(x-i);
  end;
  j:=i;
  cycle:=0;
  cnt:=0;
  while (true) do
  begin
    if (cycle<>0) and (j=i) then break;
    inc(cycle);
    if (j>=x) then j:=j-x else
    begin
      j:=w-(x-j);
      inc(cnt);
    end;
  end;
  time:=0;
  while (b<>i) do
  begin
    if (c<=a) then begin writeln(time); halt; end;
    dec(c);
    inc(time);
    if (b>=x) then b:=b-x else
    begin
      b:=w-(x-b);
      dec(a);
    end;
  end;
  if (c<=a) then begin writeln(time); halt; end;
  raz:=cycle-cnt;
  d:=(c-a-1) div raz;
  c:=c-cycle*d;
  a:=a-cnt*d;
  time:=time+cycle*d;
  while (c>a) do
  begin
    dec(c);
    if (b>=x) then b:=b-x else
    begin
      dec(a);
      b:=w-(x-b);
    end;
    inc(time);
  end;
  writeln(time);
end.


program way_out;

const
  tfi = '';//'507c.inp';
  tfo = '';//'507c.out';

var
  n,h,res : int64;
  fi,fo : text;

procedure input;
  begin
    assign(fi,tfi);
    reset(fi);
    read(fi,h,n);
    dec(n);
    close(fi);
  end;

function power(i : longint) : int64;
  var tmp : int64;
  begin
    if i = 0 then exit(1);
    tmp := power(i div 2);
    tmp := tmp*tmp;
    if i mod 2 = 1 then tmp := tmp*2;
    exit(tmp);
  end;

function getbit(stt,i : int64) : int64;
  begin
    exit((stt shr (i - 1)) and 1);
  end;

procedure process;
  var count,i : longint;
  begin
    res := h;
    count := 0;
    for i := h downto 1 do
      begin
        if count <> getbit(n,i) then
          begin
            res := res + power(i) - 1;
          end
        else count := 1 - count;
      end;
  end;

procedure output;
  begin
    assign(fo,tfo);
    rewrite(fo);
    write(fo,res);
    close(fo);
  end;

begin
  input;
  process;
  output;
end.


const eps=0.00001;
var
 x,y,d:extended;
 d1:longint;
begin
readln(x,y);
d:=sqrt(sqr(x)+sqr(y));
if abs(d-round(d))<eps then writeln('black') else
if ((x>0)and(y>0))or((x<0)and(y<0)) then
 begin
  d1:=trunc(d);
  if odd(d1) then writeln('white')
   else writeln('black');
 end else
 begin
  d1:=trunc(d);
  if odd(d1) then writeln('black')
   else writeln('white');
 end
end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var n : double;
begin
 read (n);

 write (2*n - ceil(n / 2):0:0);

 readln;
 readln;
end.


const
  dx:array[1..4] of longint=(0,1,0,-1);
  dy:array[1..4] of longint=(1,0,-1,0);

var
  i,tx,ty,deltax,deltay,xl,yl,n:longint;
  ch:char;
  s:array[0..102] of longint;
  evex,evey:array[0..102] of longint;

begin
  readln(xl,yl);

  while not eoln do
  begin
    inc(n);
    read(ch);
    if ch='U' then s[n]:=1;
    if ch='R' then s[n]:=2;
    if ch='D' then s[n]:=3;
    if ch='L' then s[n]:=4;
  end;

  if (xl=0) and (yl=0) then
  begin
    writeln('Yes');
    exit;
  end;

  for i:=1 to n do
  begin
    evex[i]:=evex[i-1]+dx[s[i]];
    evey[i]:=evey[i-1]+dy[s[i]];
    if (evex[i]=xl) and (evey[i]=yl) then
    begin
      writeln('Yes');
      exit;
    end;
  end;

  deltax:=evex[n];deltay:=evey[n];
  for i:=n downto 1 do
  begin
    tx:=xl-evex[i];ty:=yl-evey[i];
    if (deltax=0) and (tx<>0) then continue;
    if (deltay=0) and (ty<>0) then continue;
    if ((deltax=0) and (tx=0)) and ((deltay=0) and (ty=0)) then
    begin
      writeln('Yes');exit;
    end;
    if ((deltax=0) and (tx=0)) then
      if ((ty mod deltay=0) and (ty div deltay>0)) then
      begin
        writeln('Yes');exit;
      end
      else
        continue;
    if ((deltay=0) and (ty=0)) then
      if ((tx mod deltax=0) and (tx div deltax>0)) then
      begin
        writeln('Yes');exit;
      end
      else
        continue;

    if ((tx mod deltax=0) and (tx div deltax>0)) and ((ty mod deltay=0) and (ty div deltay>0)) and ((tx div deltax)=(ty div deltay)) then
    begin
      writeln('Yes');exit;
    end;
  end;
  writeln('No');
end.


var n,i,ans:longint; a:array[1..120] of longint;

procedure qsort(l,r:longint);
var
  i,j,x1,y1,m: longint;
begin
  i:=l;
  j:=r;
  m:=(l+r) div 2;
  x1:=a[m];
  repeat
    while a[i]<x1 do inc(i);
    while a[j]>x1 do dec(j);
    if i<=j then
     begin
      y1:=a[i];
      a[i]:=a[j];
      a[j]:=y1;
      inc(i);
      dec(j);
     end;
  until i>j;
  if l<j then qsort(l,j);
  if i<r then qsort(i,r);
end;

begin

  readln(n);
  //n:=100;
  for i:=1 to n do
  begin
    read(a[i]);
  // a[i]:=i;
  end;
  qsort(1,n);
  i:=2;
  while i<=n do
  begin
    ans:=ans+a[i]-a[i-1];
    i:=i+2;
  end;
  write(ans);
end.


var n, i, sm, good, t : longint;
    a, ans : array[1..105] of longint;

begin
    readln(n);
    sm := 0;
    for i := 1 to n do
    begin
        read(a[i]);
        sm := sm + a[i];
    end;
    good := a[1]; t := 0;
    for i := 2 to n do
    begin
        if (2 * a[i] <= a[1]) then
        begin
            good := good + a[i];
            inc(t);
            ans[t] := i;
        end;
    end;
    if (2 * good <= sm) then writeln(0)
    else
    begin
        writeln(t + 1);
        write(1, ' ');
        for i := 1 to t do write(ans[i], ' ');
    end;
end.


var n:integer;
function gcd(a,b:integer):integer;
begin
  if (a mod b)=0 then exit(b)
  else exit(gcd(b,(a mod b)));
end;
procedure trys;
var i:integer;
begin
  readln(n);
  i:=(n div 2);
  if i=n-i then dec(i);
  while (i>1) and (gcd(i,n-i)<>1) do dec(i);
  writeln(i,' ',n-i);
end;
begin
 trys;
end.


var
  i,j,m,n,k,p,b,g:longint;
  ans:longint;
begin
  readln(b); readln(g);
  readln(n);
  for i:=0 to n do
    begin
      j:=n-i;
      if (i<=b)and(j<=g) then
        inc(ans);
    end;
  writeln(ans);
end.


program cardgame;
var st1,st2:string;
    i:byte;

function check:boolean;
  begin
    readln(st1);
    for i:=1 to 5 do
      begin
        read(st2);
	      if (pos(st1[1],st2)<>0) or (pos(st1[2],st2)<>0) then exit(True);
      end;
    exit(False);
  end;

begin
  if check then write('YES') else write('NO');
end.


uses math;
const eps=1e-8;
type
	atype=record
			pl:extended;
			flag:longint;
		end;
var
event:array[0..4010] of atype;
p:array[0..4010] of record
					x,y:extended;
				end;
r:array[0..4010] of extended;
all,across:longint;

function fsqrt(x:extended):extended;
begin if x<0 then exit(0) else exit(sqrt(x)); end;

function farccos(x:extended):extended;
begin if x<-1 then exit(pi);
	if x>1 then exit(0);
	exit(arccos(x));
end;

function adjust(x:extended):extended;
begin while x<-eps do x:=x+2*pi;
	while x+eps>2*pi do x:=x-2*pi;
	exit(x);
end;

function cmp(const a,b:atype):boolean;
begin if abs(a.pl-b.pl)<eps then exit(a.flag<b.flag) else exit(a.pl<b.pl); end;

procedure sort(l,r:longint);
var i,j:longint;
    x,y:atype;
begin i:=l; j:=r;
	x:=event[(l+r)>>1];
	repeat
		while cmp(event[i],x) do inc(i);
		while cmp(x,event[j]) do dec(j);
		if not(i>j) then
		begin y:=event[i];
			event[i]:=event[j];
			event[j]:=y;
			inc(i); j:=j-1;
		end;
	until i>j;
	if l<j then sort(l,j);
	if i<r then sort(i,r);
end;

procedure ins(t1,t2:extended);
begin t1:=adjust(t1); t2:=adjust(t2);
	if t1>t2 then inc(across);
	inc(all); event[all].pl:=t1; event[all].flag:=1;
	inc(all); event[all].pl:=t2; event[all].flag:=-1;
end;

procedure lemon;
var n,i,base,ans,now,i2,Kallow:longint;
    theta,alpha,beta,dis:extended;
begin readln(n,Kallow); ans:=1;
	for i:=1 to n do readln(p[i].x,p[i].y,r[i]);
	for base:=1 to n do
	begin all:=0; across:=0;
		for i:=1 to n do
			if i<>base then
			begin dis:=fsqrt(sqr(p[i].x-p[base].x)+sqr(p[i].y-p[base].y));
				theta:=arctan2(p[i].y-p[base].y,p[i].x-p[base].x);
				alpha:=farccos((r[base]-r[i])/dis);		//outer cut
				beta:=farccos((r[i]+r[base])/dis);		//inner cut
				ins(theta-alpha,theta-beta);
				ins(theta+beta,theta+alpha);
			end;
		sort(1,all);
		i:=1; now:=across;
		while i<=all do
		begin i2:=i;
			while (i<=all)and(abs(event[i].pl-event[i2].pl)<eps) do begin inc(now,event[i].flag); inc(i); end;
			if now+1>ans then ans:=now+1;
		end;
	end;
	writeln(int64(ans)*Kallow+n+int64(Kallow)*(Kallow-1) div 2);
end;

begin
{$ifndef ONLINE_JUDGE}
	assign(input,'128E.in');
	reset(input);
{$endif}
lemon;
end.