#include <stdio.h>
#include <stdlib.h>
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
typedef struct
{
int year,month,day;
}Day;
Day day1,day2;
//判断是不是闰年
int leap(int year)
{
if(year%400==0||(year%4==0&&year%100!=0)) return 1;
return 0;
}
//获得某一个月份的天数值
int getdays(int year,int mymonth)
{
if(leap(year)&&mymonth==2) return 29;
return month[mymonth-1];
}
//向后添加一天
void addDay()
{
if(day1.day<getdays(day1.year,day1.month))
day1.day++;
else{
day1.day=1;
day1.month++;
if(day1.month>12)
{
day1.month=1;
day1.year++;
}
}
}
//向前添加一天
void subDay()
{
if(day2.day>1)
day2.day--;
else{
day2.month--;
if(day2.month<=0)
{
day2.month=12;
day2.year--;
}
day2.day=getdays(day2.year,day2.month);
}
}
int main()
{
int n;
scanf("%d",&n);
int i;
int j;
int myDay;
for(i=0;i<n;i++)
{
day2.year=day1.year=2013;
day2.month= day1.month=3;
day2.day=day1.day=24;
scanf("%d",&myDay);
for(j=0;j<myDay;j++)
{
addDay();
subDay();
}
printf("%d/",day1.year);
if(day1.month<10) printf("0%d/",day1.month);
else printf("%d/",day1.month);
if(day1.day<10) printf("0%d ",day1.day);
else printf("%d ",day1.day);
printf("%d/",day2.year);
if(day2.month<10) printf("0%d/",day2.month);
else printf("%d/",day2.month);
if(day2.day<10) printf("0%d\n",day2.day);
else printf("%d\n",day2.day);
}
return 0;
}