#include <stdio.h>
int main(void)
{
int year,month,date,flag=0,year1,month1,date1,flag1=0;
int sum,sum1,temp;
scanf("%d.%d.%d",&year,&month,&date);
if(1990 > year || month > 12 ||month < 1 || date < 1||date >31)
{
printf("invalid input\n" );
return -1;
}
switch(month){
case 4:
case 6:
case 9:
case 11:
if(date>30)
{
printf("invalid input\n" );
return -1;
}
case 2:
if(year1%4==0&&year%10!=0||year%100==0)
{
if(date>29)
{
printf("invalid input\n" );
return -1;
}
}
else
{
if(date>28)
{
printf("invalid input\n" );
return -1;
}
}
default:
break;
}
for(year1=1990;year1<=year;year1++)
{
if(year1%4==0&&year1%10!=0||year1%100==0)
flag+=1;
else flag1+=1;
}
sum=366*flag+365*flag1;
sum1=0;
for(int a=12;a>=month;a--)
{
switch(a)
{
case 1: case 3: case 5: case 7: case 8: case 10: case 12 : temp=31;break;
case 4: case 6: case 9: case 11: temp=30;break;
case 2:
{
if(year1%4==0&&year1%10!=0||year1%100==0)
temp=29;
else temp=28;
}
break;
default: temp=0;
}
sum1+=temp;
}
sum=sum-sum1+date;
if(sum%5==0||sum%5==4)
{
printf("He is having a rest!\n");
}
else printf("He is working!\n");
}