Program II;


var s:string[21];
    c:string[4];
    r,m,d,k,pom,pommm:integer;
    cis,pomm:longint;
    
    

begin


readln(s);
c:='boy';


while s<>'end' do
begin

if ((length(s)>11) or (length(s)<10)) then writeln('invalid')

    else
    begin
	val(s[1],pom,k);
	r:=pom*10;
	val(s[2],pom,k);
	r:=r+pom;
	if ((r>=20) and (r<=53) and (length(s)=10)) then
	    begin
		val(s[5],pom,k);
		d:=pom*10;
		val(s[6],pom,k);
		d:=d+pom;
		if ((d>=1) and (d<=31)) then
		    begin
		    val(s[3],pom,k);
		    m:=pom*10;
		    val(s[4],pom,k);
		    m:=m+pom;
		    if (m>50) then begin m:=m-50; c:='girl'; end;
		    if ((m>=1) and (m<=12)) then
			begin
			if ((m=2) and (d<=29)) then 
				begin
				if (r mod 4<>0) then begin
				    if d<=28 then writeln(c)
				    else writeln('invalid');
				    end;
				if (r mod 4=0) then writeln(c);
				end
			 else
			 if (((m=4) or (m=6) or (m=9) or (m=11)) and (d<=30)) then writeln(c)
			    else
			    if (d<=31) then writeln(c)
			    else writeln('invalid');
			
			end;
		    
		    end;
	    end
	
	    else if ( (((r>=54) and (r<=99)) or ((r>=0) and(r<=9)) and (length(s)=11))  ) then
		begin
		    val(s[5],pom,k);
		    d:=pom*10;
		    val(s[6],pom,k);
		    d:=d+pom;
		    
		    if ((d>=1) and (d<=31)) then
			begin
			val(s[3],pom,k);
			m:=pom*10;
			val(s[4],pom,k);
			m:=m+pom;
			
			
			val(s[8],pomm,k);
			cis:=pomm*100;
			val(s[9],pomm,k);
			cis:=cis+pomm*10;
			val(s[10],pomm,k);
			cis:=cis+pomm*1;
			val(s[11],pomm,k);
			{cis:=cis;}
			
			cis:=cis+ (r*10000000 + m*100000 + d*1000);
			
			pommm:=(cis mod 11) *10;
			
			pommm:=pommm+pomm;
			
			if ((pommm mod 11)=0) then
			begin
			
			if (m>50) then begin m:=m-50; c:='girl'; end;
			if ((m>=1) and (m<=12)) then
			    begin
			    if ((m=2) and (d<=29)) then 
			    		begin
			    		if (r mod 4<>0) then begin 
			    		    if d<=28 then writeln(c)
			    		    else writeln('invalid') 
			    		    end;
			    		if (r mod 4=0) then writeln(c);
					end
			    else
			    if (((m=4) or (m=6) or (m=9) or (m=11)) and (d<=30)) then writeln(c)
			    else
			    if (d<=31) then writeln(c)
			    else writeln('invalid');
			    end;
			end
			else writeln('invalid');
			end;
			
		    
		
		
		end
		else writeln('invalid');
	
	
    
    end;
r:=0;
c:='boy';
m:=0;
d:=0;
readln(s);
end;

end.