/*这题果然跨年,烦*/ #include <iostream> #include <cstdio> using namespace std; int m1[12]= {31,29,31,30,31,30,31,31,30,31,30,31}; int m2[12]= {31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int n; scanf("%d",&n); int year,month,day,add; while(scanf("%d%d%d%d",&year,&month,&day,&add)!=EOF){ int month2; int day2=day+add; for(int i=month-1;;++i){ if(i>11) { year++; i=(i+1)%12-1; } if((year%4==0&&year%100!=0)||year%400==0){ month2=i+1; if(day2<=m1[i]){ break; } day2=day2-m1[i]; } else{ month2=i+1; if(day2<=m2[i]){ break; } day2=day2-m2[i]; } } printf("%d-%02d-%02d\n",year,month2,day2); } }