Qwerty the Ranger arrived to the Diatar system with a very important task. He should deliver a special carcinogen for scientific research to planet Persephone. This is urgent, so Qwerty has to get to the planet as soon as possible. A lost day may fail negotiations as nobody is going to pay for an overdue carcinogen.You can consider Qwerty's ship, the planet Persephone and the star Diatar points on a plane. Diatar is located in the origin of coordinate axes — at point (0, 0). Persephone goes round Diatar along a circular orbit with radius R in the counter-clockwise direction at constant linear speed vp (thus, for instance, a full circle around the star takes  of time). At the initial moment of time Persephone is located at point (xp, yp).At the initial moment of time Qwerty's ship is at point (x, y). Qwerty can move in any direction at speed of at most v (v > vp). The star Diatar is hot (as all stars), so Qwerty can't get too close to it. The ship's metal sheathing melts at distance r (r < R) from the star.Find the minimum time Qwerty needs to get the carcinogen to planet Persephone.

The first line contains space-separated integers xp, yp and vp ( - 104 ≤ xp, yp ≤ 104, 1 ≤ vp < 104) — Persephone's initial position and the speed at which it goes round Diatar. The second line contains space-separated integers x, y, v and r ( - 104 ≤ x, y ≤ 104, 1 < v ≤ 104, 1 ≤ r ≤ 104) — The intial position of Qwerty's ship, its maximum speed and the minimum safe distance to star Diatar. It is guaranteed that r2 < x2 + y2, r2 < xp2 + yp2 and vp < v.

Print a single real number — the minimum possible delivery time. The answer will be considered valid if its absolute or relative error does not exceed 10 - 6.

uses
  math;

const
  eps=1e-8;
  inf=1e9;

var
  d3,d1,d2,a,b,c,tmp,ans,x01,y01,x02,y02,ta,ox,oy,kt,t,xp,yp,vp,x,y,v,r,rv,lt,rt:extended;
  it:longint;

  function dist(x1,y1,x2,y2:extended):extended;
    begin
      dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    end;

  function inseg(x,y,x1,y1,x2,y2:extended):boolean;
    begin
      inseg:=abs(dist(x,y,x1,y1)+dist(x,y,x2,y2)-dist(x1,y1,x2,y2))<eps;
    end;

  procedure cross(a,b,c,r:extended;var x01,y01,x02,y02:extended);
    var
      dd,x00,y00,d:extended;

    begin
      d:=sqrt(a*a+b*b);
      a:=a/d;b:=b/d;c:=c/d;
      d:=abs(c);
      if (d+eps>r)then begin
        x01:=inf;y01:=inf;
        x02:=inf;y02:=inf;
        exit;
      end;
      dd:=r*r-d*d;
      if (abs(dd)<eps)then dd:=0;
      dd:=sqrt(dd);
      x00:=-a*c;
      y00:=-b*c;
      x01:=x00-b*dd;
      y01:=y00+a*dd;
      x02:=x00+b*dd;
      y02:=y00-a*dd;
    end;

begin
  {cross(1,-1,0,2,x01,y01,x02,y02);
  writeln(x01:0:10,' ',y01:0:10,' ',x02:0:10,' ',y02:0:10);
  exit;}
  read(xp,yp,vp);
  read(x,y,v,r);
  rv:=sqrt(xp*xp+yp*yp);
  lt:=0;rt:=1e9;
  for it:=1 to 1000 do begin
    t:=(lt+rt)/2;
    kt:=t*vp*180/(PI*rv);
    kt:=kt*PI/180;
    tmp:=arctan2(yp,xp);
    kt:=kt+tmp;
    ox:=rv*cos(kt);
    oy:=rv*sin(kt);
    if (abs(ox)<eps)then ox:=0;
    if (abs(oy)<eps)then oy:=0;
    a:=oy-y;
    b:=x-ox;
    c:=-a*x-b*y;
    cross(a,b,c,r,x01,y01,x02,y02);
    if (not inseg(x01,y01,x,y,ox,oy))or
       (not inseg(x02,y02,x,y,ox,oy))
         then ans:=dist(x,y,ox,oy)
         else begin
           d1:=sqrt(x*x+y*y);
           d2:=sqrt(ox*ox+oy*oy);
           d3:=dist(x,y,ox,oy);
           ta:=arccos((d1*d1+d2*d2-d3*d3)/(2*d1*d2));
           ta:=ta-(arccos(r/d1)+arccos(r/d2));
           while (ta<-eps)do ta:=ta+2*PI;
           if (2*PI-ta<ta)then ta:=2*PI-ta;
           ta:=ta*360/(2*PI);
           ans:=2*PI*r*ta/360;
           ans:=ans+sqrt(d1*d1-r*r)+sqrt(d2*d2-r*r);
         end;
    if (ans/v<t+eps)
      then rt:=t
      else lt:=t;
  end;
  writeln(t:0:10);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var k,b,ta,tb,tc,td,xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=vp*time/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 //write(x:0:9,' ',y:0:9,' ',txp:0:9,' ',typ:0:9,' ');
 //writeln(txp:0:9,' ',typ:0:9);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 1');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 2');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 //writeln(nt:0:9);
 tt:=dis(x,y,0,0)*nt;
 //writeln(txp:0:9,' ',typ:0:9,' ',tt:0:9);}
 k:=(y-typ)/(x-txp);
 b:=y-k*x;
 ta:=k;tb:=-1;tc:=b;
 td:=abs(tc)/sqrt(ta*ta+tb*tb);
 if ((tt<0) and (td>=r)) or (tt>=r) then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 3');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 //writeln(tttt:0:9,' in 4');
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
//   write(mid:0:9,' ');
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var k,b,ta,tb,tc,td,xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=vp*time/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 k:=(y-typ)/(x-txp);
 b:=y-k*x;
 ta:=k;tb:=-1;tc:=b;
 td:=abs(tc)/sqrt(ta*ta+tb*tb);
 if ((tt<0) and (td>=r)) or (tt>=r) then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

program pr1;

{$APPTYPE CONSOLE}

     type point=record x,y:double; end;
          tar=record r1,r2,h:double; end;
const  modul=1046527;  modul7=1000000007;
 eps=1e-11;  nnn=2000000;
 label 1,2,3,4;
var kolshag,w,h,pmax,imax,p1,p2,nn,n1,n2,kolm,j1,i,kk,t,tt,k,i3,i0,i1,i2,i4,step,j:longint;
p,kolraz,rr,s1,mmin,kolmax,x0,y0,vx,vy,f,ii,n,ot,besk,m,k1,k2,a2,jj:int64;
pzav,ott:double;  tt2,ch,ch1,ch2:char;
sss,ss,ss1,ss2:string;
st,fin,a,b,c:point;
ddx,ddy,x,y,z:array [-2000..200000] of double;
gr:array[-2001..2001,-2001..2001] of boolean;
pad: array[-2001..2001] of boolean;
s:int64;
ugt,ugg,vv,xx,yy,xp,yp,vp,l,r, dt,dx,dy,aa,bb,cc,pp,t1,t2,x1,x2,tmin:double;
 oldmingor,oldminver,mingor,minver:array[0..1000] of longint;
sss1,sss2,sss3: string;

flag2,flag1,flag:boolean;
rzav,pprod:double;
name:array[0..200] of string;
function min(a,b:double):double;begin min:=b;if a<b then min:=a;  end;
function max(a,b:longint):longint;begin max:=b;if a>b then max:=a;  end;

function nod(a,b:longint):longint; var p,t:longint;
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 dd(x,y:point):double;
begin dd:=sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));     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 luck(a:longint):boolean;
 var i,j,k:longint;flag:boolean;
 c: array[0..10] of longint;
begin
  flag:=true;  j:=0;
  k:=a;
  while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); }  end;
 for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;
 luck:=flag;
end;

   function ttt(ss:string):longint; var i,j,k,s:longint; fl:boolean;
 begin k:=length(ss);
   s:=0; for i:=1 to k do s:=10*s+ord(ss[i])-48;
      ttt:=s;
 end;

 {   function dist2(xx,yy:double):double;  var i,j:longint; dd,pp,tt:double;
      begin
         dd:=1e+20;
         for i:=1 to n do
             begin
                 pp:=abs(xx*a[i]+yy*b[i]-c[i])/sqrt(a[i]*a[i]+b[i]*b[i]);
                if pp<dd then dd:=pp;
             end;
        dist2:=(dd*dd);
      end;
   }
 function dist(a,b,c:point):double;
 var p,q,d1,d2,l,r:double; ll,rr,xx,yy:point;
 begin
    l:=0;r:=1; ll:=a;rr:=b;
    repeat p:=l+(r-l)*0.4; q:=l+(r-l)*0.6;
       xx.x:=ll.x+(rr.x-ll.x)*0.4;
       xx.y:=ll.y+(rr.y-ll.y)*0.4;
       yy.x:=ll.x+(rr.x-ll.x)*0.6;
       yy.y:=ll.y+(rr.y-ll.y)*0.6;
       d1:=dd(xx,c); d2:=dd(yy,c);
       if d1<d2 then begin r:=q; rr:=yy; end else begin  l:=p;ll:=xx;    end;

    until abs(l-r)<eps;
    dist:=dd(ll,c);
 end;
    function dltr(a,b:point):double;   label 33;
 var r1,r2,ot,uga,ugb,ug,x,y,l1,l2:double; cen:point;
   begin
      uga:=phi(a.x,a.y); ugb:=phi(b.x,b.y); cen.x:=0;cen.y:=0;
      ug:=min(abs(uga-ugb),2*pi-abs(uga-ugb)); r1:=dd(a,cen);r2:=dd(b,cen);
      if dist(a,b,cen)>=r then begin ot:=dd(a,b); goto 33;       end;
      l1:=sqrt(r1*r1-r*r);  l2:=sqrt(r2*r2-r*r);

      x:=arctan(l1/r);y:=arctan(l2/r);
      ot:=l1+l2+r*(ug-x-y);

 33: dltr:=ot;
   end;

         begin
{assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
}       read(xp,yp,vp);
       read(xx,yy,vv,r);
 aa:=0;bb:=10000000; ugg:=phi(xp,yp);
  while abs(aa-bb)>eps do
    begin
        cc:=(aa+bb)/2; ugt:=ugg+cc*vp/sqrt(xp*xp+yp*yp);
     a.x:=xx; a.y:=yy;
     b.x:=sqrt(xp*xp+yp*yp)*cos(ugt);
     b.y:=sqrt(xp*xp+yp*yp)*sin(ugt);
     c.x:=0;c.y:=0;
     if dltr(a,b)/vv<cc then bb:=cc else aa:=cc;
    { writeln(aa:0:5,' ',bb:0:5,' ',dltr(a,b):0:5);   }
    end;
                 writeln(cc:0:8);

  1:
     close(output);

     end.

uses math;
type
  double=extended;
  dot=record
    x,y:double;
  end;

var
  vp,lt,mid,rt,v,time,xp,yp,rr,x,y,af,r:double;
  ttp,tp,sy,oy:dot;
  i:longint;
function dis(a,b:dot):double;
begin
  dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
end;

function cj(a,b,c,d:dot):double;
begin
  cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y);
end;

function dj(a,b,c,d:dot):double;
begin
  dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);
end;

function xz(v:dot; af:double):dot;
var d1,d2:double;
begin
  d1:=cos(af); d2:=sin(af);
  xz.x:=cos(af)*v.x-sin(af)*v.y;
  xz.y:=sin(af)*v.x+cos(af)*v.y;
end;

procedure qqd(var v1,v2:dot;tp:dot);
var
  tt:dot;
  af:double;
begin
  tt:=tp;
  tt.x:=tt.x/dis(tp,oy)*r; tt.y:=tt.y/dis(tp,oy)*r;
  af:=arccos(r/dis(tp,oy));

  v1:=xz(tt,af);
  v2:=xz(tt,-af);
end;

function calc(v1,v2:dot):double;
var af:double;
begin
  af:=arccos(dj(oy,v1,oy,v2)/dis(oy,v1)/dis(oy,v2));
  calc:=af*r;
end;

function check(ti:double):boolean;
var kind:boolean;
  le,l2:double;
  v1,v2,v3,v4:dot;
begin
  check:=true;
  tp:=xz(tp,ti*vp/rr);

  le:=arccos(dj(oy,tp,oy,ttp)/dis(oy,tp)/dis(oy,ttp));
  kind:=true;
  if (dj(sy,tp,sy,oy)/dis(sy,tp)>0) then
  if (dj(sy,tp,sy,oy)/dis(sy,tp)<dis(sy,tp)) then
    if abs(cj(sy,tp,sy,oy))/dis(sy,tp)<r then kind:=false;
  if kind then check:=(dis(sy,tp)/ti<v) else begin
    qqd(v1,v2,sy);
    qqd(v3,v4,tp);
    le:=dis(sy,v1)+dis(tp,v4)+calc(v1,v4);
    l2:=dis(sy,v2)+dis(tp,v3)+calc(v2,v3);
    if l2<le then le:=l2;
    check:=(le/ti<v);
  end;

  tp:=xz(tp,-ti*vp/rr);
end;

begin
oy.x:=pi;
  oy.x:=0; oy.y:=0;
  readln(xp,yp,vp);
  tp.x:=xp; tp.y:=yp;  rr:=dis(tp,oy);
  ttp:=tp;

  readln(x,y,v,r);
  sy.x:=x; sy.y:=y;
  if dis(sy,tp)<1e-10 then begin
    writeln(0.0:0:12);
    halt;
  end;

  lt:=0; rt:=1e10;
  for i:=1 to 300 do begin
    mid:=(lt+rt)/2;
    if check(mid) then rt:=mid else lt:=mid;
  end;

  writeln(lt:0:12);
end.

program _198C_DeliveringCarcinogen;
uses math;
const eps=1e-9;
var xp,yp,vp,x,y,v,r:longint;
	theta,w,RR,x0,y0,alpha,AB,OA,OB,t0,low,high,mid,h,DG1,DG2:extended;

function viable(t:extended):boolean;
begin
	x0:=cos(theta+w*t)*RR;
	y0:=sin(theta+w*t)*RR;
	AB:=sqrt(sqr(x-x0)+sqr(y-y0));
	alpha:=abs(arctan2(y,x)-arctan2(y0,x0));
	if alpha>pi then alpha:=2*pi-alpha;
	DG1:=arccos((sqr(OA)+sqr(AB)-sqr(OB))/(2*OA*AB));
	DG2:=pi-DG1-alpha;
	h:=OA*sin(DG1);
    if (DG1<pi/2)and(DG2<pi/2)and(h<r-eps) then
    	t0:=(sqrt(sqr(OA)-sqr(r))+sqrt(sqr(OB)-sqr(r))+r*(alpha-arccos(r/OA)-arccos(r/OB)))/v
    else
		t0:=AB/v;
	exit(t0<t+eps);
end;

begin
    readln(xp,yp,vp);
	readln(x,y,v,r);
	RR:=sqrt(sqr(xp)+sqr(yp));
	w:=vp/RR;
	theta:=arctan2(yp,xp);
	OA:=sqrt(sqr(x)+sqr(y));
    OB:=RR;
	low:=0; high:=(OA+RR+2*pi*(RR+r))/v;
	repeat
		mid:=(low + high)/2;
		if viable(mid) then high:=mid else low:=mid;
	until high-low<=eps;
	writeln(high:0:8);
end.

uses math;
type
  extended=double;
const
 eps=1e-12;
var
  i,j,k:longint;
  x,y,x1,y1,v,v1,dan,l,r,r1,stx,sty,mid,w1,l3,l4,ans:double;
function dis(x,y,x1,y1:double):double;
begin
   exit(sqrt(sqr(x-x1)+sqr(y-y1)));
end;
function dot(x,y,x1,y1:double):double;
begin
   exit(x*x1+y*y1);
end;
function check(time:double):boolean;
var xnow,ynow,roranow,cida,cida1,cida2,ll,dd:double;
begin
     roranow:=w1*time;
     xnow:=x1*cos(roranow)-y1*sin(roranow);
     ynow:=y1*cos(roranow)+x1*sin(roranow);

     cida:=arccos(dot(xnow,ynow,stx,sty)/(dis(0,0,xnow,ynow)*dis(0,0,stx,sty)));

     cida1:=arccos(dan/dis(0,0,xnow,ynow));

     cida2:=arccos(dan/dis(0,0,stx,sty));

     if cida1+cida2-cida>=0 then exit(time*v-dis(xnow,ynow,stx,sty)>=0);

     dd:=(cida-cida1-cida2)*dan;

     dd:=dd+sqrt(xnow*xnow+ynow*ynow-dan*dan)+l3;

     exit(v*time-dd>=0);
end;
begin
     readln(x1,y1,v1);
     readln(stx,sty,v,dan);
     if stx=x1 then if sty=y1 then
     begin
      writeln(0);
      halt;
     end;
     l3:=sqrt(stx*stx+sty*sty-dan*dan);
     r1:=sqrt(x1*x1+y1*y1);
     w1:=v1/r1;
     l:=0;
     r:=1e8;
     while abs(r-l)>eps do
     begin
       mid:=(l+r)*0.5;if check(mid) then begin r:=mid;
       ans:=mid;
       end
       else l:=mid;
     end;
     writeln(ans:0:8);
end.

{$R-,S-,Q-,I-,O+}
const pi = 3.1415926535897932384626433832795;
var
  it,xp,yp,vp,x,y,v,r: longint;
  ll,rr,t,ang,xx,yy: extended;

function findang(x,y:extended):extended;
var
  ang: extended;
begin
  if abs(x) < 1e-9 then
  begin
    if y > 0 then findang:=0.5*pi
    else findang:=1.5*pi;
  end else
  if abs(y) < 1e-9 then
  begin
    if x > 0 then findang:=0
    else findang:=pi;
  end else
  begin
    ang:=arctan(abs(y/x));
    if (x < 0) and (y > 0) then ang:=pi-ang else
    if (x < 0) and (y < 0) then ang:=pi+ang else
    if (x > 0) and (y < 0) then ang:=2*pi-ang;
    findang:=ang;
  end;
end;

function dst(x,y:extended):extended;
var
  min: extended;
begin
  min:=abs(x-y);
  if abs(x+2*pi-y) < min then min:=abs(x+2*pi-y);
  if abs(x-2*pi-y) < min then min:=abs(x-2*pi-y);
  if abs(x+4*pi-y) < min then min:=abs(x+4*pi-y);
  if abs(x-4*pi-y) < min then min:=abs(x-4*pi-y);
  dst:=min;
end;

function go(x1,y1,x2,y2:extended):extended;
var
  ma,c1,c2,u1,u2,r1,r2,q1,q2,q3,q4,a,b,c,d,dist,d1,d2: extended;
  ok: boolean;
begin
  dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));
  if dist < 1e-9 then
  begin
    go:=dist;
    exit;
  end;
  d1:=sqrt(sqr(x1)+sqr(y1));
  d2:=sqrt(sqr(x2)+sqr(y2));
  ok:=False;
  if d1*d1 > d2*d2+dist*dist then ok:=True;
  if d2*d2 > d1*d1+dist*dist then ok:=True;
  if not ok then
  begin
    a:=y2-y1; b:=x1-x2;
    c:=-a*x1-b*y1;
    d:=abs(c)/sqrt(a*a+b*b);
    if d < r then
    begin
      c1:=sqrt(x1*x1+y1*y1-r*r);
      c2:=sqrt(x2*x2+y2*y2-r*r);
      u1:=findang(x1,y1);
      u2:=findang(x2,y2);
      r1:=arctan(c1/r);
      q1:=u1-r1; q2:=u1+r1;
      r2:=arctan(c2/r);
      q3:=u2-r2; q4:=u2+r2;
      ma:=dst(q1,q3);
      if dst(q1,q4) < ma then ma:=dst(q1,q4);
      if dst(q2,q3) < ma then ma:=dst(q2,q3);
      if dst(q2,q4) < ma then ma:=dst(q2,q4);
      dist:=c1+c2+ma*r;
    end;
  end;
  go:=dist;
end;

begin
  read(xp,yp,vp);
  read(x,y,v,r);
  ll:=0; rr:=1e9;
  for it:=1 to 500 do
  begin
    t:=(ll+rr)*0.5;
    ang:=t*vp/sqrt(xp*xp+yp*yp);
    xx:=xp*cos(ang)-yp*sin(ang);
    yy:=xp*sin(ang)+yp*cos(ang);
    if go(x,y,xx,yy) <= t*v then rr:=t
    else ll:=t;
  end;
  writeln((ll+rr)*0.5:0:17);
end.

uses math;
const pi=3.1415926535897932384626433832795;
type
  double=extended;
  dot=record
    x,y:double;
  end;

var
  vp,lt,mid,rt,v,time,xp,yp,rr,x,y,af,r:double;
  ttp,tp,sy,oy:dot;
  i:longint;
function dis(a,b:dot):double;
begin
  dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
end;

function cj(a,b,c,d:dot):double;
begin
  cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y);
end;

function dj(a,b,c,d:dot):double;
begin
  dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);
end;

function xz(v:dot; af:double):dot;
var d1,d2:double;
begin
  d1:=cos(af); d2:=sin(af);
  xz.x:=cos(af)*v.x-sin(af)*v.y;
  xz.y:=sin(af)*v.x+cos(af)*v.y;
end;

procedure qqd(var v1,v2:dot;tp:dot);
var
  tt:dot;
  af:double;
begin
  tt:=tp;
  tt.x:=tt.x/dis(tp,oy)*r; tt.y:=tt.y/dis(tp,oy)*r;
  af:=arccos(r/dis(tp,oy));

  v1:=xz(tt,af);
  v2:=xz(tt,-af);
end;

function calc(v1,v2:dot):double;
var af:double;
begin
  af:=arccos(dj(oy,v1,oy,v2)/dis(oy,v1)/dis(oy,v2));
  calc:=af*r;
end;

function check(ti:double):boolean;
var kind:boolean;
  le,l2:double;
  v1,v2,v3,v4:dot;
begin
  check:=true;
  tp:=xz(tp,ti*vp/rr);

  le:=arccos(dj(oy,tp,oy,ttp)/dis(oy,tp)/dis(oy,ttp));
  kind:=true;
  if (dj(sy,tp,sy,oy)/dis(sy,tp)>0) then
  if (dj(sy,tp,sy,oy)/dis(sy,tp)<dis(sy,tp)) then
    if abs(cj(sy,tp,sy,oy))/dis(sy,tp)<r then kind:=false;
  if kind then check:=(dis(sy,tp)/ti<v) else begin
    qqd(v1,v2,sy);
    qqd(v3,v4,tp);
    le:=dis(sy,v1)+dis(tp,v4)+calc(v1,v4);
    l2:=dis(sy,v2)+dis(tp,v3)+calc(v2,v3);
    if l2<le then le:=l2;
    check:=(le/ti<v);
  end;

  tp:=xz(tp,-ti*vp/rr);
end;

begin
  oy.x:=0; oy.y:=0;
  readln(xp,yp,vp);
  tp.x:=xp; tp.y:=yp;  rr:=dis(tp,oy);
  ttp:=tp;

  readln(x,y,v,r);
  sy.x:=x; sy.y:=y;
  if dis(sy,tp)<1e-10 then begin
    writeln(0.0:0:12);
    halt;
  end;

  lt:=0; rt:=1e10;
  for i:=1 to 300 do begin
    mid:=(lt+rt)/2;
    if check(mid) then rt:=mid else lt:=mid;
  end;

  writeln(lt:0:12);
end.

uses math;
const pi=3.1415926535897932384626433832795;
type
  double=extended;
  dot=record
    x,y:double;
  end;

var
  vp,lt,mid,rt,v,time,xp,yp,rr,x,y,af,r:double;
  ttp,tp,sy,oy:dot;
  i:longint;
function dis(a,b:dot):double;
begin
  dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
end;

function cj(a,b,c,d:dot):double;
begin
  cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y);
end;

function dj(a,b,c,d:dot):double;
begin
  dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);
end;

function xz(v:dot; af:double):dot;
var d1,d2:double;
begin
  d1:=cos(af); d2:=sin(af);
  xz.x:=cos(af)*v.x-sin(af)*v.y;
  xz.y:=sin(af)*v.x+cos(af)*v.y;
end;

function xz2(v:dot; si,co:double):dot;
begin
  xz2.x:=co*v.x-si*v.y;
  xz2.y:=si*v.x+co*v.y;

end;
procedure qqd(var v1,v2:dot;tp:dot);
var
  tt:dot;
  af,si,co:double;
begin
  tt:=tp;
  tt.x:=tt.x/dis(tp,oy)*r; tt.y:=tt.y/dis(tp,oy)*r;
  co:=r/dis(tp,oy);
  si:=1-co*co;
  if si<0 then si:=0 else si:=sqrt(si);

  v1:=xz2(tt,-si,co);
  v2:=xz2(tt,si,co);
end;

function calc(v1,v2:dot):double;
var af:double;
begin
  af:=arccos(dj(oy,v1,oy,v2)/dis(oy,v1)/dis(oy,v2));
  calc:=af*r;
end;

function check(ti:double):boolean;
var kind:boolean;
  le,l2:double;
  v1,v2,v3,v4:dot;
begin
  check:=true;
  tp:=xz(tp,ti*vp/rr);

  le:=arccos(dj(oy,tp,oy,ttp)/dis(oy,tp)/dis(oy,ttp));
  //tp:=xz(tp,-ti*vp);
  kind:=true;
  if (dj(sy,tp,sy,oy)/dis(sy,tp)>0) then
  if (dj(sy,tp,sy,oy)/dis(sy,tp)<dis(sy,tp)) then
    if abs(cj(sy,tp,sy,oy))/dis(sy,tp)<r then kind:=false;
  if kind then check:=(dis(sy,tp)/ti<v) else begin
    qqd(v1,v2,sy);
    //writeln(dj(v2,oy,v2,sy));
    qqd(v3,v4,tp);
    le:=dis(sy,v1)+dis(tp,v4)+calc(v1,v4);
    l2:=dis(sy,v2)+dis(tp,v3)+calc(v2,v3);
    if l2<le then le:=l2;
    check:=(le/ti<v);
  end;

  tp:=xz(tp,-ti*vp/rr);
end;

begin
{readln(tp.x,tp.y);
while 1=1 do begin
  read(af);
  tp:=xz(tp,af);
  tp:=xz(tp,-af);
  writeln(tp.x:0:2,' ',tp.y:0:2);
end;        }
  oy.x:=0; oy.y:=0;
  readln(xp,yp,vp);
  tp.x:=xp; tp.y:=yp;  rr:=dis(tp,oy);
  ttp:=tp;
  {time:=dis(tp,oy)/vp;
  vp:=1/time;}

  readln(x,y,v,r);
  sy.x:=x; sy.y:=y;
  if dis(sy,tp)<1e-10 then begin
    writeln(0.0:0:12);
    halt;
  end;

  lt:=0; rt:=1e10;
  for i:=1 to 300 do begin
    mid:=(lt+rt)/2;
    if check(mid) then rt:=mid else lt:=mid;
  end;

  writeln(lt:0:12);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=(vp*time)/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 tt:=dis(x,y,0,0)*nt;
 if tt>=r then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=vp*time/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 //write(x:0:9,' ',y:0:9,' ',txp:0:9,' ',typ:0:9,' ');
 //writeln(txp:0:9,' ',typ:0:9);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if nt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 1');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 if dt<=0 then
  begin
   //565656
   //writeln(dis(x,y,txp,typ):0:9,' in 1');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 2');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 //writeln(txp:0:9,' ',typ:0:9,' ',tt:0:9);
 if tt>=r then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 3');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 //writeln(tttt:0:9,' in 4');
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
//   write(mid:0:9,' ');
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=(vp*time)/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 tt:=dis(x,y,0,0)*nt;
 if tt>=r then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:double;
function dis(x1,y1,x2,y2:double):double;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:double):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=(vp*time)/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x-t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if dt<0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x-t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 if tt>=r then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:real;
function dis(x1,y1,x2,y2:real):real;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:real):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=vp*time/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 if tt>=r then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=(vp*time)/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x-t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if dt<0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x-t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 if tt>=r then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=vp*time/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 //write(x:0:9,' ',y:0:9,' ',txp:0:9,' ',typ:0:9,' ');
 //writeln(txp:0:9,' ',typ:0:9);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if nt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 1');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 if dt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 1');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<=0 then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 2');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 //writeln(txp:0:9,' ',typ:0:9,' ',tt:0:9);
 if tt>=r then
  begin
   //writeln(dis(x,y,txp,typ):0:9,' in 3');
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 //writeln(tttt:0:9,' in 4');
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
//   write(mid:0:9,' ');
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

//Copyright @ 2012, Mike Rush, All rights reserved.
uses math;
var xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;
function dis(x1,y1,x2,y2:extended):extended;
begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;
function check(time:extended):boolean;
begin
 rp:=dis(xp,yp,0,0);
 nt:=(vp*time)/rp;
 txp:=xp*cos(nt)-yp*sin(nt);
 typ:=yp*cos(nt)+xp*sin(nt);
 t1x:=-x;t1y:=-y;
 t2x:=t1x+txp;t2y:=t1y+typ;
 nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));
 if nt<0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 t1x:=-txp;t1y:=-typ;
 t2x:=t1x+x;t2y:=t1y+y;
 dt:=(t1x*t2y-t2x*t1y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));
 if dt<0 then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=dis(x,y,0,0)*nt;
 if tt>=r then
  begin
   ttt:=dis(x,y,txp,typ);
   ttt:=ttt/v;
   if ttt<=mid then exit(true);
   exit(false);
  end;
 tt:=x*txp+y*typ;
 tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));
 tt1:=arccos(r/dis(txp,typ,0,0));
 tt2:=arccos(r/dis(x,y,0,0));
 ttt:=tt-tt1-tt2;
 tttt:=ttt*r;
 tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));
 tttt:=tttt/v;
 if tttt<=mid then exit(true);
 exit(false);
end;
begin
 readln(xp,yp,vp);
 readln(x,y,v,r);
 if (xp=x) and (yp=y) then
  begin writeln(0.0:0:9);halt;end;
 left:=0;right:=1E5;
 while abs(left-right)>1E-10 do
  begin
   mid:=(left+right)/2;
   if check(mid) then right:=mid-(1E-10)
                 else left:=mid+(1E-10);
  end;
 writeln(left:0:9);
end.

program _198C_DeliveringCarcinogen;
uses math;
const eps=1e-9;
var xp,yp,vp,x,y,v,r:longint;
	theta,w,RR,x0,y0,alpha,AB,OA,OB,t0,low,high,mid,h:extended;

function viable(t:extended):boolean;
begin
	x0:=cos(theta+w*t)*RR;
	y0:=sin(theta+w*t)*RR;
	alpha:=abs(arctan2(y,x)-arctan2(y0,x0));
	if alpha>pi then alpha:=2*pi-alpha;
	AB:=sqrt(sqr(x-x0)+sqr(y-y0));
	if abs(AB)>eps then h:=sin(alpha)*OA*OB/AB else h:=(OA+OB)/2;
    if (alpha>pi/2)and(h<r-eps) then
		t0:=(sqrt(sqr(OA)-sqr(r))+sqrt(sqr(OB)-sqr(r))+r*(alpha-arccos(r/OA)-arccos(r/OB)))/v
    else
		t0:=AB/v;
	exit(t0<t+eps);
end;

begin
    readln(xp,yp,vp);
	readln(x,y,v,r);
	RR:=sqrt(sqr(xp)+sqr(yp));
	w:=vp/RR;
	theta:=arctan2(yp,xp);
	OA:=sqrt(sqr(x)+sqr(y));
    OB:=RR;
	low:=0; high:=(OA+RR+2*pi*(RR+r))/v;
	repeat
		mid:=(low + high)/2;
		if viable(mid) then high:=mid else low:=mid;
	until high-low<=eps;
	writeln(high:0:8);
end.


Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty certificate from a local hospital, he is going to use his knowledge of local doctor's handwriting to make a counterfeit certificate of illness. However, after writing most of the certificate, Andrey suddenly discovered that doctor's signature is impossible to forge. Or is it?For simplicity, the signature is represented as an $$$n\times m$$$ grid, where every cell is either filled with ink or empty. Andrey's pen can fill a $$$3\times3$$$ square without its central cell if it is completely contained inside the grid, as shown below. xxxx.xxxx Determine whether is it possible to forge the signature on an empty $$$n\times m$$$ grid.

The first line of input contains two integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 1000$$$). Then $$$n$$$ lines follow, each contains $$$m$$$ characters. Each of the characters is either '.', representing an empty cell, or '#', representing an ink filled cell.

If Andrey can forge the signature, output "YES". Otherwise output "NO". You can print each letter in any case (upper or lower).

NoteIn the first sample Andrey can paint the border of the square with the center in $$$(2, 2)$$$.In the second sample the signature is impossible to forge.In the third sample Andrey can paint the borders of the squares with the centers in $$$(2, 2)$$$ and $$$(3, 2)$$$:   we have a clear paper: ............  use the pen with center at $$$(2, 2)$$$. ####.####...  use the pen with center at $$$(3, 2)$$$. ############ In the fourth sample Andrey can paint the borders of the squares with the centers in $$$(3, 3)$$$ and $$$(3, 5)$$$.

var n, m, i, j, k, h: longint;
    a, b: array[1..1000, 1..1000] of char;
    ck: boolean;
    tmp: string;
begin
    read(n, m);
    for i := 1 to n do
        for j := 1 to m do b[i, j] := '.';
    readln;
    for i := 1 to n do
    begin
        read(tmp);
        readln;
        for j := 1 to m do
        begin
            a[i, j] := tmp[j];
        end;
    end;
    for i := 1 to n do
        for j := 1 to m do
        begin
            if(i + 2 <= n) and (j + 2 <= m) then
                if(a[i, j] = '#') and (a[i, j + 1] = '#') and (a[i, j + 2] = '#') and (a[i + 1, j] = '#') and (a[i + 1, j + 2] = '#') and (a[i + 2, j] = '#') and (a[i + 2, j + 1] = '#') and (a[i + 2, j + 2] = '#') then
                begin
                    for k := i to i + 2 do
                    begin
                        for h := j to j + 2 do if(h <> j + 1) or (k <> i + 1) then b[k, h] := '#';
                    end;
                    if b[i + 1, j + 1] <> '#' then b[i + 1, j + 1] := '.';
                end;
        end;
    for i := 1 to n do
        for j := 1 to m do
            if a[i, j] <> b[i, j] then ck := true;
    if ck = true then write('NO')
    else write('YES');
end.

var n,m,i,j:longint;
a,f:array[0..1000,0..1000]of char;
begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do read(a[i,j]);
  readln;
  end;
fillchar(f,sizeof(f),'.');
for i:=2 to n-1 do
  for j:=2 to m-1 do
    if(a[i-1,j]='#')and(a[i+1,j]='#')and(a[i,j-1]='#')and(a[i,j+1]='#')and(a[i-1,j-1]='#')and(a[i+1,j+1]='#')and(a[i+1,j-1]='#')and(a[i-1,j+1]='#')then
      begin
      f[i-1,j]:='#';f[i+1,j]:='#';f[i-1,j-1]:='#';f[i-1,j+1]:='#';
      f[i,j-1]:='#';f[i,j+1]:='#';f[i+1,j-1]:='#';f[i+1,j+1]:='#';
      end;
for i:=1 to n do
  for j:=1 to m do
    if a[i,j]<>f[i,j] then
      begin
      writeln('NO');close(input);close(output);halt;
      end;
writeln('YES');
close(input);close(output);
end.

var a:array[-10..1010,-10..1010] of char;
f:array[-10..1010,-10..1010] of boolean;
i,j,n,m:longint;
begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do
    read(a[i,j]);
  readln;
  end;
for i:=1 to n do
  for j:=1 to m do
    if (a[i-1,j]='#')and(a[i-1,j-1]='#')and(a[i-1,j+1]='#')and
    (a[i,j-1]='#')and(a[i,j+1]='#')and
    (a[i+1,j]='#')and(a[i+1,j-1]='#')and(a[i+1,j+1]='#') then
      begin
      f[i-1,j]:=true;f[i-1,j-1]:=true;f[i-1,j+1]:=true;
      f[i+1,j]:=true;f[i+1,j-1]:=true;f[i+1,j+1]:=true;
      f[i,j-1]:=true;f[i,j+1]:=true;
      end;
for i:=1 to n do
  for j:=1 to m do
    if (a[i,j]='#') and (f[i,j]=false) then
      begin
      writeln('NO');
      close(input);close(output);
      halt;
      end;
writeln('YES');
close(input);close(output);
end.

var n,m,i,j:longint;
a,f:array[0..10001,0..10001] of char;

begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do read(a[i,j]);
  readln;
  end;
for i:=1 to n do
  for j:=1 to m do
    f[i,j]:='.';
for i:=2 to n-1 do
  begin
  for j:=2 to m-1 do
    begin
    if (a[i,j+1]='#') and (a[i,j-1]='#') and (a[i+1,j]='#') and (a[i-1,j]='#')
    and (a[i-1,j-1]='#') and (a[i-1,j+1]='#') and (a[i+1,j-1]='#') and (a[i+1,j+1]='#') then
      begin
      f[i,j+1]:='#';f[i,j-1]:='#';f[i+1,j]:='#';f[i-1,j]:='#';
      f[i-1,j-1]:='#';f[i-1,j+1]:='#';f[i+1,j-1]:='#';f[i+1,j+1]:='#';
      end;
    end;
  end;
for i:=1 to n do
  for j:=1 to m do
    if f[i,j]<>a[i,j] then
      begin
      writeln('NO');
      close(input);close(output);
      halt;
      end;
writeln('YES');
close(input);close(output);
end.

const d:array[1..8,1..2] of longint=((1,0),(0,1),(-1,0),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));
var n,m,i,j,k:longint;
f:boolean;
a:array[1..1000,1..1000] of char;
b:array[1..1000,1..1000] of boolean;

begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do
    read(a[i,j]);
  readln;
  end;
for i:=2 to n-1 do
  for j:=2 to m-1 do
    begin
    f:=true;
    for k:=1 to 8 do
      if a[i+d[k,1],j+d[k,2]]='.' then f:=false;
    if f then
      begin
      for k:=1 to 8 do
        b[i+d[k,1],j+d[k,2]]:=true;
      end;
    end;
for i:=1 to n do
  for j:=1  to m do
    if (a[i,j]='#') and (b[i,j]=false) then
      begin
      write('NO');
      close(input);close(output);halt;
      end;
write('YES');
close(input);close(output);
end.

var n,m,i,j:Longint;
f,a:array [1..1002,1..1002] of char;
begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out'); rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do
    begin
    read(a[i,j]);
    f[i,j]:='.';
    end;
  readln;
  end;
for i:=1 to n do
  for j:=1 to m do
    if (a[i,j]='#') and (a[i,j+1]='#') and (a[i,j+2]='#') and (a[i+1,j]='#') and (a[i+1,j+2]='#') and (a[i+2,j]='#') and (a[i+2,j+1]='#') and (a[i+2,j+2]='#') then
      begin
      f[i,j]:='#';f[i,j+1]:='#';f[i,j+2]:='#';
      f[i+1,j]:='#';f[i+1,j+2]:='#';
      f[i+2,j]:='#';f[i+2,j+1]:='#';f[i+2,j+2]:='#';
      end;
for i:=1 to n do
  for j:=1 to m do
    if f[i,j]<>a[i,j] then
      begin
      writeln('NO');
      close(input);close(output);
      halt;
      end;
writeln('YES');
close(input);close(output);
end.

const
 fi='';
 fo='';
var
 mt:array[0..1000,0..1000]of char;
 a:array[0..1000,0..1000]of longint;
 n,m:longint;
 f:text;

procedure doc;
var
 i,j:longint;
begin
 assign(f,fi);
 reset(f);
 readln(f,n,m);
 for i:=1 to n do
 begin
  for j:=1 to m do
   read(f,mt[i,j]);
  readln(f);
 end;
 close(f);
end;

function kt(i,j:longint):boolean;
begin
 if(mt[i-1,j-1]='#')and(mt[i-1,j]='#')and(mt[i-1,j+1]='#')and(mt[i,j-1]='#')and(mt[i,j+1]='#')and(mt[i+1,j-1]='#')and(mt[i+1,j]='#')and(mt[i+1,j+1]='#')then kt:=true
 else kt:=false;
end;

procedure xuly;
var
 i,j:longint;
begin
 for i:=1 to n do
  for j:=1 to m do
   if(kt(i,j))then
   begin
    a[i-1,j-1]:=1;
    a[i-1,j]:=1;
    a[i-1,j+1]:=1;
    a[i,j-1]:=1;
    a[i,j+1]:=1;
    a[i+1,j-1]:=1;
    a[i+1,j]:=1;
    a[i+1,j+1]:=1;
   end;
end;

procedure xuat;
var
 i,j:longint;
 ktt:boolean;
begin
 assign(f,fo);
 rewrite(f);
 ktt:=true;
 for i:=1 to n do
 begin
  for j:=1 to m do
   if(mt[i,j]='#')and(a[i,j]=0)then
   begin
    ktt:=false;
    break;
   end;
  if(ktt=false)then break;
 end;
 if(ktt=true)then write(f,'YES')
 else write(f,'NO');
 close(f);
end;

begin
 doc;
 xuly;
 xuat;
end.

type mass=array[1..1000,1..1000]of char;
var
   a,b:mass; f:boolean;
   i,j,k,l,n,m:integer;
begin
   readln(n,m);
   for i:=1 to n do
    begin
        for j:=1 to m do
        begin
            read(a[i,j]);
            b[i,j]:='.'
        end;
        readln;
    end;
   for i:=1 to n-2 do
    for j:=1 to m-2 do
    begin
     f:=true;
     for k:=0 to 2 do
      for l:=0 to 2 do
       begin
          if (k<>l) and (a[i+k,j+l]='.')
          then f:=false
          else if (k<>1) and (l<>1) and (a[i+k,j+l]='.')
               then f:=false;
       end;
      if f then
      for k:=0 to 2 do
      for l:=0 to 2 do
       begin
          if (k<>l)
          then  b[i+k,j+l]:='#'
          else if (k<>1) and (l<>1)
               then b[i+k,j+l]:='#';
       end;
     end;
   f:=true;
   for i:=1 to n do
   begin
    for j:=1 to m do
     if (a[i,j]='#')
     then if (b[i,j]<>'#')
          then f:=false
   end;
   if f
   then writeln('YES')
   else writeln('NO')
end.

var     m,n:longint;
        a,b: array[0..1001,0..1001] of Boolean;

procedure main;
var     i,j: longint;
begin
        for i:=1 to m-2 do
        for j:=1 to n-2 do
        begin
                if  (a[i,j]) and (a[i,j+1]) and (a[i,j+2])
                and (a[i+1,j])  and (a[i+1,j+2])
                and (a[i+2,j]) and (a[i+2,j+1]) and (a[i+2,j+2]) then
                begin
                b[i,j]:=true;
                b[i,j+1]:=true;
                b[i,j+2]:=true;
                b[i+1,j]:=true;
                b[i+1,j+2]:=true;
                b[i+2,j]:=true;
                b[i+2,j+1]:=true;
                b[i+2,j+2]:=true;
                end;
        end;
        for i:=1 to m do
        for j:=1 to n do if a[i,j]<>b[i,j] then
        begin
                write('NO');exit;
        end;
        write('YES')
end;

procedure inp;
var     i,j: longint;
        c: char;
begin
        fillchar(a,sizeof(a),False);
        fillchar(a,sizeof(a),False);
        readln(m,n);
        for i:=1 to m do
        begin
                for j:=1 to n do
                begin
                        read(c);
                        if c='#' then a[i,j]:= True;
                end;
                readln;
        end;
end;

begin
        inp;
        main;
end.

var i,j,n,m,k,o,s:longint;
a,b:array[0..1001,0..1001] of boolean;
c:char;
x:array[1..8] of longint=(1,1,-1,-1,0,0,1,-1);
y:array[1..8] of longint=(1,-1,1,-1,1,-1,0,0);
x1:boolean;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      read(c);
      if c='.' then a[i,j]:=true;
    end;
    readln;
  end;
  for i:=2 to n-1 do
  for j:=2 to m-1 do
  begin
    x1:=false;
    for k:=1 to 8 do
    if a[i+x[k],j+y[k]] then
     begin x1:=true;break;end;
    if not(x1) then
    for k:=1 to 8 do
    b[i+x[k],j+y[k]]:=true;
  end;
  for i:=1 to n do
  for j:=1 to m do
  if a[i,j]=b[i,j] then begin writeln('NO');halt;end;
  writeln('YES');
end.

var
  i,j,n,m:longint;
  a:array[0..1001,0..1001] of char;
  f:array[0..1001,0..1001] of boolean;
procedure doit(x,y:longint);
  begin
    if (a[x+1,y]='.') or (a[x+2,y]='.') or (a[x,y+1]='.') or (a[x,y+2]='.') or (a[x+1,y+2]='.') or (a[x+2,y+1]='.') or (a[x+2,y+2]='.') then exit;
    f[x,y]:=true; f[x+1,y]:=true; f[x+2,y]:=true; f[x,y+1]:=true; f[x,y+2]:=true; f[x+1,y+2]:=true; f[x+2,y+1]:=true; f[x+2,y+2]:=true;
  end;
begin
  readln(n,m);
  for i:=1 to n do
    begin
      for j:=1 to m do
        read(a[i,j]);
      readln;
    end;
  for i:=1 to n-2 do
    for j:=1 to m-2 do
      if a[i,j]='#' then doit(i,j);
  for i:=1 to n do
    for j:=1 to m do
      if (a[i,j]='#') and (f[i,j]=false) then begin writeln('NO'); halt; end;
  writeln('YES');
end.

 var i,j,n,m:longint;
 a,b:array [1..1001,1..1001] of char;
  begin
 {assign (input,'input.txt');
 reset (input);
 assign (output,'output.txt');
 rewrite (output);}

 read (n,m);

 for i:=1 to n do
  begin
   readln;
  for j:=1 to m do
   read (a[i,j]);

  end;

 for i:=2 to n-1 do
  for j:=2 to m-1 do
   begin
    if (a[i,j+1]='#') and (a[i-1,j+1]='#') and (a[i-1,j]='#') and (a[i-1,j-1]='#') and
       (a[i,j-1]='#') and (a[i+1,j-1]='#') and (a[i+1,j]='#') and (a[i+1,j+1]='#') then
        begin
         b[i,j+1]:='#';
         b[i-1,j+1]:='#';
         b[i-1,j]:='#';
         b[i-1,j-1]:='#';
         b[i,j-1]:='#';
         b[i+1,j-1]:='#';
         b[i+1,j]:='#';
         b[i+1,j+1]:='#';
        end;

   end;

 for i:=1 to n do
  for j:=1 to m do
   if a[i,j]='#' then
    if b[i,j]<>'#' then
     begin
      writeln ('NO');
      halt;
     end;

 writeln ('YES');

  end.

program _1061B;

var n, m, i, j: integer;
    s: String;
    g: boolean;
    nm : array[1..1000, 1..1000] of char;
    nm2 : array[1..1000, 1..1000] of boolean;

begin
  readln(n, m);
  g := true;
  for i := 1 to n do
    begin
      readln(s);
      for j := 1 to m do
        nm[i, j] := s[j];
    end;

  for i := 2 to n-1 do
    for j := 2 to m-1 do
      begin
        if (nm[i-1, j] = '#') and (nm[i-1, j-1] = '#') and (nm[i-1, j+1] = '#') and (nm[i+1, j+1] = '#') and (nm[i+1, j-1] = '#') and (nm[i+1, j] = '#') and (nm[i, j-1] = '#') and (nm[i, j+1] = '#') then begin
          nm2[i-1, j] := true;
          nm2[i-1, j-1] := true;
          nm2[i-1, j+1] := true;
          nm2[i+1, j+1] := true;
          nm2[i+1, j-1] := true;
          nm2[i+1, j] := true;
          nm2[i, j-1] := true;
          nm2[i, j+1] := true;
        end;
      end;

  for i := 1 to n do
    for j := 1 to m do
      if (nm[i, j] = '#') and (nm2[i, j] <> true) then g := false;

  if g = true then
    write('YES')
  else
    write('NO');
end.

program p;
var n, m: integer;
    a, b: array [-5..1005, -5..1005] of boolean;
    ch: char;

begin
readln(n, m);
for var g:=1 to n do
  begin
  for var g1:=1 to m do
    begin
    read(ch);
    if ch='#' then a[g, g1]:=true
    end;
  readln
  end;

for var g:=2 to n-1 do
  for var g1:=2 to m-1 do
    if a[g-1, g1] and a[g-1, g1+1] and a[g-1, g1-1] and
        a[g+1, g1] and a[g+1, g1+1] and a[g+1, g1-1] and
        a[g, g1+1] and a[g, g1-1] then
    begin
    for var g2:=g1-1 to g1+1 do
      begin
      b[g+1, g2]:=true;
      b[g-1, g2]:=true
      end;
    b[g, g1-1]:=true;
    b[g, g1+1]:=true
    end;
if a=b then write('yes')
  else write('no')
end.

                   const eps=0.000000001;  besk1=200000008;  nnn=4600000;
             { modul=1000000007;  }
             modul=998244353;
   besk=4000000000000000000;
   label 22,1,2,3,4;
    type    real=extended;   double=extended;
    mas=array [-100000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nnn] of longint;mass1=^mass;
    var nn,t3,t4,t5,t6,posmax,tmax,kold,kk,d,n,j2,ttt,ppp,kol,sq,sum,h,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,prod,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,aa,bb,cc,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,m,smin,cen:int64;
   i2,i3,step2,k1,k2,pp0,mask,k,i1,j1,step1, step, i,j:longint;
   y:mas;
   x,z:array[-1..15000012] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;
    alpha,phi:extended;
    zzan:array[-1..2000,-1..2000] of boolean;
    sumkonfig,konfig:array[-1000..200000,-1..10] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..150] of longint;
    z0,num,x1,y1,z1,z2,kolnul,a,fact,next,prev,xx,yy,str,s,name,dnew, voltay,l,r,c,day,b:mas;
    zz:array[0..125000000] of byte;
    ppole:array[-10..1002,-10..1005] of char;
    pole,ddd,dd2,dd3,dd4:array[-10..4200,-10..1020] of char;
    dd,ddnew:array[-1..1200,-1..2100] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    sss1,sss2:string;
    def,left,right,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
    ss1,ss2,ss:string;ch,ch1,ch2:char;
    pr,hesh,numright,dr: array [-10..1060,-10..1060] of extended;
    s3,s2,s1:array[-100..500000] of string;

    grr :array [-10..2010,-10..2010] of boolean;
    maxpr:array[0..nnn] of string;
    sss:array[-10..nnn] of string;
     tx,ty,vel,ott,v0,v1,s0,t0:int64;
     zv:point;
     ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     mash,sqx,sqy,ottt,aaa,bbb,ccc:extended;
     xxx,yyy,yot:double;
       flag2,flag,flag1:boolean;

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

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

procedure udal(p:longint);
begin  next[prev[p]]:=next[p]; prev[next[p]]:=prev[p]; 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 summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

{     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;
 }

    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 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 shr 1); degg:=p*p mod modul;   end;

end;

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

   prost:=fl;
 end;
 }
function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

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

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;

 function ff(gr:int64):boolean;

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

    end;
  { writeln(' cc= ',cc);
  } cc:=min(cc+3,m+1);
   repeat dec(cc) until y[cc]<=gr;
   if y[cc]=gr then fl:=true else fl:=false;
  ff:=fl;
end;

function f1(p:int64):int64;
begin
    if p>=x[n] then f1:=n else f1:=xx[p];
    if p=0 then f1:=0;

end;

function f2(p:int64):int64;
begin
  if p>=y[m] then f2:=m else f2:=yy[p];
  if p=0 then f2:=0;
end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
         readln(n,m);
          for i:=1 to n do begin for j:=1 to m do read(pole[i,j]); readln;  end;
        for i:=1 to n do for j:=1 to m do
          begin
             if pole[i+1,j]='#' then inc(dd[i,j]);
             if pole[i-1,j]='#' then inc(dd[i,j]);
             if pole[i,j+1]='#' then inc(dd[i,j]);
             if pole[i,j-1]='#' then inc(dd[i,j]);
             if pole[i+1,j+1]='#' then inc(dd[i,j]);
             if pole[i-1,j+1]='#' then inc(dd[i,j]);
             if pole[i+1,j-1]='#' then inc(dd[i,j]);
             if pole[i-1,j-1]='#' then inc(dd[i,j]);
          end;

{ for i:=1 to n do begin for j:=1 to m do write(dd[i,j],' '); writeln;  end;
 }
     for i:=1 to n do for j:=1 to m do ppole[i,j]:='.';

      for i:=1 to n do for j:=1 to m do if dd[i,j]=8 then
        begin
           ppole[i+1,j]:='#';
           ppole[i-1,j]:='#';
           ppole[i,j+1]:='#';
           ppole[i,j-1]:='#';
           ppole[i+1,j+1]:='#';
           ppole[i-1,j+1]:='#';
           ppole[i+1,j-1]:='#';
           ppole[i-1,j-1]:='#';

        end;

     {  for i:=1 to n do begin for j:=1 to m do write(ppole[i,j]); writeln;  end;
      }
       flag:=true;
       for i:=1 to n do for j:=1 to m do if pole[i,j]<>ppole[i,j] then flag:=false;

        if flag then write('YES') else write('NO');

1:             close(output);
end.

var n, m, i, j, k, h: longint;
    a, b: array[1..1000, 1..1000] of char;
    ck: boolean;
    tmp: string;
begin
    read(n, m);
    for i := 1 to n do
        for j := 1 to m do b[i, j] := '.';
    readln;
    for i := 1 to n do
    begin
        read(tmp);
        readln;
        for j := 1 to m do
        begin
            a[i, j] := tmp[j];
        end;
    end;
    for i := 1 to n do
        for j := 1 to m do
        begin
            if(i + 2 <= n) and (j + 2 <= m) then
                if(a[i, j] = '#') and (a[i, j + 1] = '#') and (a[i, j + 2] = '#') and (a[i + 1, j] = '#') and (a[i + 1, j + 2] = '#') and (a[i + 2, j] = '#') and (a[i + 2, j + 1] = '#') and (a[i + 2, j + 2] = '#') then
                begin
                    for k := i to i + 2 do
                    begin
                        for h := j to j + 2 do if(h <> j + 1) or (k <> i + 1) then b[k, h] := '#';
                    end;
                    if b[i + 1, j + 1] <> '#' then b[i + 1, j + 1] := '.';
                end;
        end;
    for i := 1 to n do
        begin
        for j := 1 to m do write(b[i, j]);
        writeln;
        end;
    for i := 1 to n do
        for j := 1 to m do
            if a[i, j] <> b[i, j] then ck := true;
    if ck = true then write('NO')
    else write('YES');
end.

var n,m,i,j:longint;
f,f1:boolean;
a:array[0..10001,0..10001] of char;
begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do
    read(a[i,j]);
  readln;
  end;
for i:=2 to n-1 do
  for j:=2 to m-1 do
    if a[i,j]='.' then
      begin
      f1:=true;f:=true;
      if a[i-1,j]='.' then f:=false;
      if a[i+1,j]='.' then f:=false;
      if a[i,j-1]='.' then f:=false;
      if a[i,j+1]='.' then f:=false;
      if a[i-1,j-1]='.' then f:=false;
      if a[i-1,j+1]='.' then f:=false;
      if a[i+1,j-1]='.' then f:=false;
      if a[i+1,j+1]='.' then f:=false;
      if f=false then
        begin
        writeln('NO');
        close(input);close(output);halt;
        end;
      end;
if (f1=false)and(n=3)and(n=3) then
  writeln('NO')
else
  writeln('YES');
close(input);close(output);
end.

var n,m,i,j,x,y,o,k:longint;f:boolean;
b:array[-500..500,-500..500]of longint;
a:array[-500..500,-500..500]of char;
begin
//assign(input,'zj.in');reset(input);
//assign(output,'zj.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to n do read(a[i,j]);
  readln;
  end;
for i:=1 to n do
  for j:=1 to n do
    if a[i,j]='.' then
      begin
      f:=true;
      for k:=i-1 downto i-m+1 do
        if a[k,j]<>'.' then f:=false;
      if f then
        for k:=i downto i-m+1 do inc(b[k,j]);
      f:=true;
      for k:=i+1 to i+m-1 do
        if a[k,j]<>'.' then f:=false;
      if f then
        for k:=i to i+m-1 do inc(b[k,j]);
      f:=true;
      for k:=j-1 downto j-m+1 do
        if a[i,k]<>'.' then f:=false;
      if f then
        for k:=j downto j-m+1 do inc(b[i,k]);
      f:=true;
      for k:=j+1 to j+m-1 do
        if a[i,k]<>'.' then f:=false;
      if f then
        for k:=j to j+m-1 do inc(b[i,k]);
      end;
x:=1;y:=1;
for i:=1 to n do
  for j:=1 to n do
    if b[i,j]>o then
      begin
      o:=b[i,j];
      x:=i;y:=j;
      end;
write(x,' ',y);
close(input);close(output);
end.

var n,m,i,j,s:longint;
a:array[-5..10001,-5..10001]of char;
begin
///assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
fillchar(a,sizeof(a),'.');
for I:=1 to n do
  begin
  for j:=1 to m do read(a[i,j]);
  readln;
  end;
for I:=1 to n do
  for j:=1 to m do
    if a[i,j]='#' then
      begin
      if(a[i+1,j+1]<>'.')and(n=3)and(m=3)and(i=1)and(j=1)then
        begin
        write('NO');
        close(input);close(output);halt;
        end;
      if(i<n-1)and(j<m-1)then
        if(a[i+1,j+1]='.')and(a[i+1,j-3]='.')then
          begin
          write('NO');
          close(input);close(output);halt;
          end;
      s:=0;
      if a[i+1,j]='.' then inc(s);
      if a[i-1,j]='.' then inc(s);
      if a[i,j-1]='.' then inc(s);
      if a[i,j+1]='.' then inc(s);
      if s>=3 then
        begin
        write('NO');
        close(input);close(output);halt;
        end;
      end;
write('YES');
close(input);close(output);
end.

var n,m,i,j:longint;f,f1:boolean;
a:array[0..1001,0..1001] of char;
begin
//assign(input,'wz.in');reset(input);
//assign(output,'wz.out');rewrite(output);
readln(n,m);
for i:=1 to n do
  begin
  for j:=1 to m do
    read(a[i,j]);
  readln;
  end;
f:=true;
for i:=2 to n-1 do
  for j:=2 to m-1 do
    if a[i,j]='.' then
      begin
      f1:=true;
      if a[i-1,j]='.' then f:=false;
      if a[i+1,j]='.' then f:=false;
      if a[i,j-1]='.' then f:=false;
      if a[i,j+1]='.' then f:=false;
      if a[i-1,j-1]='.' then f:=false;
      if a[i-1,j+1]='.' then f:=false;
      if a[i+1,j-1]='.' then f:=false;
      if a[i+1,j+1]='.' then f:=false;
      if f=false then
        begin
        writeln('NO');
        close(input);close(output);halt;
        end;
      end;
if (f)and(f1)or(f1=false)and((n<>3)or(m<>3)) then writeln('YES')
else writeln('NO');
close(input);close(output);
end.

type mass=array[1..1000,1..1000]of char;
var
   a,b:mass; f:boolean;
   i,j,k,l,n,m:integer;
begin
   readln(n,m);
   for i:=1 to n do
    begin
        for j:=1 to m do
        begin
            read(a[i,j]);
            b[i,j]:='.'
        end;
        readln;
    end;
   for i:=1 to n-2 do
    for j:=1 to m-2 do
    begin
     for k:=0 to 2 do
      for l:=0 to 2 do
       begin
          if (k<>l)
          then  b[i+k,j+l]:='#'
          else if (k<>1) and (l<>1)
               then b[i+k,j+l]:='#';
       end;
     end;
   f:=true;
   for i:=1 to n do
   begin
    for j:=1 to m do
     if (a[i,j]='#') and (b[i,j]<>'#')
     then f:=false
   end;
   if f
   then writeln('YES')
   else writeln('NO')
end.

type mass=array[1..1000,1..1000]of char;
var
   a,b:mass; f:boolean;
   i,j,k,l,n,m:integer;
begin
   readln(n,m);
   for i:=1 to n do
    begin
        for j:=1 to m do
        begin
            read(a[i,j]);
            b[i,j]:='.'
        end;
        readln;
    end;
   for i:=1 to n-2 do
    for j:=1 to m-2 do
    begin
     for k:=0 to 2 do
      for l:=0 to 2 do
       begin
          if (k<>l)
          then  b[i+k,j+l]:='#'
          else if (k<>1) and (l<>1)
               then b[i+k,j+l]:='#';
       end;
     end;
   f:=true;
   for i:=1 to n do
   begin
    for j:=1 to m do
     if (a[i,j]='#')
     then if (b[i,j]<>'#')
          then f:=false
   end;
   if f
   then writeln('YES')
   else writeln('NO')
end.

type mass=array[1..1000,1..1000]of char;
var
   a,b:mass;
   i,j,n,m:integer;
begin
   readln(n,m);
   for i:=1 to n do
    begin
        for j:=1 to m do
        begin
            read(a[i,j]);
            b[i,j]:='.'
        end;
        readln;
    end;
end.


Given an n × n table T consisting of lowercase English letters. We'll consider some string s good if the table contains a correct path corresponding to the given string. In other words, good strings are all strings we can obtain by moving from the left upper cell of the table only to the right and down. Here's the formal definition of correct paths:Consider rows of the table are numbered from 1 to n from top to bottom, and columns of the table are numbered from 1 to n from left to the right. Cell (r, c) is a cell of table T on the r-th row and in the c-th column. This cell corresponds to letter Tr, c.A path of length k is a sequence of table cells [(r1, c1), (r2, c2), ..., (rk, ck)]. The following paths are correct:   There is only one correct path of length 1, that is, consisting of a single cell: [(1, 1)];  Let's assume that [(r1, c1), ..., (rm, cm)] is a correct path of length m, then paths [(r1, c1), ..., (rm, cm), (rm + 1, cm)] and [(r1, c1), ..., (rm, cm), (rm, cm + 1)] are correct paths of length m + 1. We should assume that a path [(r1, c1), (r2, c2), ..., (rk, ck)] corresponds to a string of length k: Tr1, c1 + Tr2, c2 + ... + Trk, ck.Two players play the following game: initially they have an empty string. Then the players take turns to add a letter to the end of the string. After each move (adding a new letter) the resulting string must be good. The game ends after 2n - 1 turns. A player wins by the following scenario:   If the resulting string has strictly more letters "a" than letters "b", then the first player wins;  If the resulting string has strictly more letters "b" than letters "a", then the second player wins;  If the resulting string has the same number of letters "a" and "b", then the players end the game with a draw. Your task is to determine the result of the game provided that both players played optimally well.

The first line contains a single number n (1 ≤ n ≤ 20). Next n lines contain n lowercase English letters each — table T.

In a single line print string "FIRST", if the first player wins, "SECOND", if the second player wins and "DRAW", if the game ends with a draw.

NoteConsider the first sample:Good strings are strings: a, ab, ac, abd, acd.The first player moves first and adds letter a to the string, as there is only one good string of length 1. Then the second player can add b or c and the game will end with strings abd or acd, correspondingly. In the first case it will be a draw (the string has one a and one b), in the second case the first player wins. Naturally, in this case the second player prefers to choose letter b and end the game with a draw.Consider the second sample:Good strings are: x, xa, xay.We can see that the game will end with string xay and the first player wins.

{$ INLINE ON}
program B354;
const
        inp='';
        oup='';
        max=21;
        maxbit=1 shl 21;
        Goal:array[1..3] of string=('FIRST','DRAW','SECOND');
var
        F:text;
        Dp:array [1..max*2,0..maxbit] of longint;
        check:array [1..max*2,0..maxbit] of boolean;
        A:array [1..max] of string[max];
        N:longint;
(*              *)
procedure nhap;
var     i:integer;
begin
        assign(f,inp);  reset(f);
        readln(f,N);
        for i:=1 to n do readln(F,A[i]);
        close(f);
end;
(*              *)
function IsUp(Mask,Vt:longint):boolean; inline;
begin
        if (mask and (1 shl vt))>0 then exit(true)
        else exit(false);
end;
(*              *)
procedure change1(pos,vt:longint; var x,y:longint); inline;
begin
        if vt<=n then
                begin
                        y:=pos;
                        x:=(vt+1-pos);
                        exit;
                end;
        if vt>n then
                begin
                        y:=pos+vt-n;
                        x:=n-pos+1;
                        exit;
                end;
end;
(*              *)
function change2(x,y,vt:longint):longint; inline;
begin
        if vt<=n then
                begin
                        exit(vt+1-x);
                end;
        if vt>n then
                begin
                        exit(n-x+1);
                end;
end;
(*              *)
function up(mask,len,hx,hy,vt:longint):longint; inline;
var     now,i,vtx,vty:longint;
begin
        now:=0;
        for i:=1 to len do if isup(mask,i-1) then
                begin
                        change1(i,vt,vtx,vty);
                        vtx:=vtx+1;
                        if (vtx>0) and (vtx<n+1) and (vty>0) and (vty<n+1) then
                        begin
                                if A[vtx,vty]=A[hx,hy] then
                                        now:=now or (1 shl (change2(vtx,vty,vt+1)-1));
                        end;
                        vtx:=vtx-1;
                        vty:=vty+1;
                        if (vtx>0) and (vtx<n+1) and (vty>0) and (vty<n+1) then
                        begin
                                if A[vtx,vty]=A[hx,hy] then
                                        now:=now or (1 shl (change2(vtx,vty,vt+1)-1));
                        end;
                        vty:=vty-1;
                end;
        exit(now);
end;
(*              *)
function maxvalue(x,y:longint):longint; inline;
begin
        if x>y then exit(x) else exit(y);
end;
(*              *)
function value(x,y,vt:longint):longint; inline;
var     cur:longint;
begin
        cur:=0;
        if A[x,y]='a' then cur:=1;
        if A[x,y]='b' then cur:=-1;
        if vt mod 2 = 0 then cur:=-cur;
        exit(cur);
end;
(*              *)
function Dpsearch(i,bit:longint):longint;
var     j,len,vtx,vty:longint;
        res,newmask:longint;
begin
        if (i=2*n-1) then exit(0);
        if check[i,bit] then exit(Dp[i,bit]);
        if i<=n then len:=i else len:=2*n-i;
        res:=-maxlongint;
        for j:=1 to len do if IsUp(Bit,j-1) then
                begin
                        change1(j,i,vtx,vty);
                        vtx:=vtx+1;
                        if (vtx>0) and (vtx<n+1) and (vty>0) and (vty<n+1) then
                                begin
                                        Newmask:=up(Bit,Len,vtx,vty,i);
                                        if newmask>0 then res:=maxvalue(res,value(vtx,vty,i+1)-Dpsearch(i+1,newmask));
                                end;
                        vtx:=vtx-1;
                        vty:=vty+1;
                        if (vtx>0) and (vtx<n+1) and (vty>0) and (vty<n+1) then
                                begin
                                        Newmask:=up(Bit,Len,vtx,vty,i);
                                        if newmask>0 then res:=maxvalue(res,value(vtx,vty,i+1)-Dpsearch(i+1,newmask));
                                end;
                        vty:=vty-1;
                end;
        check[i,bit]:=true;
        Dp[i,bit]:=res;
        exit(res);
end;
(*              *)
procedure xuat;
var     finalres,x:longint;
begin
        assign(f,oup);  rewrite(f);
        finalres:=value(1,1,1)-Dpsearch(1,1);
        if finalres>0 then x:=1;
        if finalres=0 then x:=2;
        if finalres<0 then x:=3;
        writeln(f,goal[x]);
        close(f);
end;
(*              *)
BEGIN
        nhap;
        xuat;
END.