#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);
    ytom=y;
    if(m==12&&d==31)
    {
        ytom++;
        mtom=1;
        dtom=1;
    }
    else if((m31==true&&d==31)||(m31==false&&d==30)||(february==true&&february29==false&&d==28)||(february29==true&&d==29))
    {
        mtom=m+1;
        dtom=1;
    }
    else
    {
        ytom=y;
        mtom=m;
        dtom=d+1;
    }
    cout<<dtom<<" "<<mtom<<" "<<ytom;
    return 0;
}