#include <iostream>
using namespace std;

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

class Date {
  private:
    int year;
    int month;
    int day;
  public:
    void input() {
        cin >> year >> month >> day;
    }
    void display() {
        cout << year << "-";
        if (month < 10) cout << 0;
        cout << month << "-";
        if (day < 10) cout << 0;
        cout << day << endl;
    }
    void operator ++() {
        this->day++;
        if (this->day > m[this->month])  {
            this->day -= m[this->month];
            this->month++;
            if (this->month > 12) {
                this->month -= 12;
                this->year++;
            }
        }
    }
};

int main() {
    int n;
    cin >> n;
    Date d[n];
    for (int i = 0; i < n; i++) {
        d[i].input();
        ++d[i];
        d[i].display();
    }

}