#include<iostream>
using namespace std;
//a,b,c和y1, y2(1850 ≤ y1, y2 ≤ 2050)
//公元y1年到公元y2年间的每年的a月的第b个星期c的日期。
//1850年1月1日是星期二 365%7=1 366%7=2
//2014/05/11
int monarr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
/*int sum(int mon,int isrun)
{
int num=0;
for(int i=1;i<=mon;i++)
{
num+=monarr[i];
if(i==2&&isrun==1)
num++;
}
return num;
}*/
bool run(int n)
{
if(n%400==0 || (n%4==0&&n%100!=0))
return true;
else
return false;
}
int main()
{
//freopen("11.txt","r",stdin);
int isrun;
int num;
int a,b,c,y1,y2;
cin>>a>>b>>c>>y1>>y2;
int st=1850;
int yweek=2;//st年第一天星期几
int mweek;//当月第一天星期几
int day;//
while(st<y1)
{
if(run(st)==1)
{
yweek= (yweek+2)%7==0?7:(yweek+2)%7;
}
else
{
yweek= (yweek+1)%7==0?7:(yweek+1)%7;
}
st++;
}//算到了y1年第一天星期几
while(st<=y2)
{
isrun=run(st);
num=0;
if(isrun==1)
monarr[2]=29;
for(int i=1;i<=a-1;i++)
{
num+=monarr[i];
}
mweek=(yweek+num)%7; //st年前a-1个月 a月第一天星期几
if(mweek==0)
mweek=7;
day=8-mweek+7*(b-1)+c;
if(c>=mweek)
{
day-=7;
}
if(day>monarr[a])
{
cout<<"none"<<endl;
}
else
{
cout<<st;
if(a<10)
cout<<"/0"<<a;
else
cout<<"/"<<a;
if(day<10)
cout<<"/0"<<day;
else
cout<<"/"<<day;
cout<<endl;
}
if(isrun==1)
{
yweek= (yweek+2)%7;
if(yweek==0)
yweek=7;
}
else
{
yweek= (yweek+1)%7;
if(yweek==0)
yweek=7;
}
st++;
monarr[2]=28;
}
return 0;
}