#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d, m, y, dtom=0, mtom=0, ytom=0;
    cin>>d>>m>>y;
    bool visokosna=((y%4==0&&y%100!=0)||(y%400==0));
    bool february=(m==2);
    bool february29=(visokosna);
    bool m31=(m==1||m==3||m==5||m==7||m==8||m==10||m==12);
    if(d==31&&m==12)
    {
        ytom=y+1;
        dtom=1;
        mtom=1;
    }
    else
    {
        ytom=y;
        if((m31==true&&d==31)||(m31==false&&d==30)||(february29==true&&d==29)||(february29==false&&february==true&&d==28))
        {
            mtom=m+1;
            dtom=1;
        }
        else
        {
            mtom=m;
            dtom=d+1;
        }
    }
    cout<<dtom<<" "<<mtom<<" "<<ytom;
    return 0;
}