#include <iostream>
#include <iomanip>
using namespace std;

int daytable[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

class Date{
    public:
        int year;
        int month;
        int day;
        Date(int y,int m,int d){
            year=y;
            month=m;
            day=d;
        }
        void addday(){
            day++;
            if(day>daytable[month]){
                day-=daytable[month];
                if(month==12)
                    month=1;
                else
                    month++;
            }
        }
        void format_output(){
            cout<<year<<'-';
            cout<<setw(2)<<setfill('0')<<month;
            cout<<'-';
            cout<<setw(2)<<setfill('0')<<day<<endl;
        }
};

int main(){
    int n;
    int year;
    int month;
    int day;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>year>>month>>day;
        Date d1(year,month,day);
        d1.addday();
        d1.format_output();
    }
}