#include <iostream>
using namespace std;

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

int main() {
    int m;
    while (scanf("%d", &m) != EOF) { // 注意 while 处理多个 case
        for (int j = 0; j < m; j++) { // m个日期
            int year, month, day;
            scanf("%d%d%d", &year, &month, &day);
            day++;
            if (day > days[month]) {
                month++;
                day = 1;
            }
            if (month > 12) {
                year++;
                month = 1;
            }      
            printf("%d-%02d-%02d\n", year, month, day);
        }

    }
}
// 64 位输出请用 printf("%lld")