//日期类 北理 2024/1/4
//http://t.cn/E9RJUp4
#include <iostream>
using namespace std;
bool ifLeap(int year){
return (year%400==0)||(year%100!=0&&year%4==0);
}
int main() {
int n;
int year,month,date;
int caltab[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
cin>>n;
while(n){
n--;
cin>>year>>month>>date;
//注意,此处是需要判断平闰年的,测试用例不够全面,没有涉及这种考虑
if(ifLeap(year)) caltab[2]=29;
else caltab[2]=28;
//整体思路很简洁,直接给日期+1,依次判断月、年是否需要更新
date+=1;
if(date>caltab[month]){
month+=1;
date=1;
if(month>12){
year+=1;
month=1;
}
}
printf("%04d-%02d-%02d\n",year,month,date);
}
return 0;
}