#include <iostream> using namespace std; int daytab[2][13] = { {0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31} }; int IsRunNian(int y) { return ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)); } int main() { int n; cin>>n; while(n--){ int year,month,day; cin>>year>>month>>day; int a = IsRunNian(year); if(day==daytab[a][month]){ month += 1; if(month>12){ year += 1; month = 1; day = 1; } day = 1; }else{ day += 1; } if(month<=9 && day<=9){ cout<<year<<"-0"<<month<<"-0"<<day<<endl; }else if(month<=9 && day>9){ cout<<year<<"-0"<<month<<"-"<<day<<endl; }else if(month>9 && day<=9){ cout<<year<<"-"<<month<<"-0"<<day<<endl; }else{ cout<<year<<"-"<<month<<"-"<<day<<endl; } } }