#include<cstdio> int main() { int Mday[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n; scanf("%d", &n); for (int i = 0; i <= n; ++i) { int year, mon, day; while (scanf("%04d%02d%02d", &year, &mon, &day) != EOF) { ++day; if (day > Mday[mon]) { day = 1; ++mon; if (mon > 12) { ++year; mon = 1; } } printf("%04d-%02d-%02d\n", year, mon, day); } } }