#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long day,mounth,year;
    cin>>day>>mounth>>year;
    if((year%4==0&&year%400!=0)||(year%400==0))
    {
        if(day == 29)
        {
            cout<<"1 3 "<<year;
        }
        else if(day==31&&mounth==12)
        {
            cout<<"1 1 "<<year+1;
        }
        else if((mounth==1 || mounth==3 || mounth==5 || mounth==7 || mounth==8 || mounth==10) && day==31)
        {
            cout<<1<<" "<<mounth+1<<" "<<year;
        }
        else if((mounth==4 || mounth==6 || mounth==9 || mounth==11) && day==30)
        {
            cout<<1<<" "<<mounth+1<<" "<<year;
        }
        else
          {
               cout<<day+1 <<" "<<mounth<<" "<<year;
          }
    }
    else{
            if(day ==28)
            {
                cout<<"1 3"<<" "<<year;
            }
           else if(day==31&&mounth==12)
        {
            cout<<"1 1"<<" "<<year+1;
        }
        else if((mounth==1 || mounth==3 || mounth==5 || mounth==7 || mounth==8 || mounth==10) &&day==31)
        {

            cout<<1<<" "<<mounth+1<<" "<<year;
        }
        else
          {
               cout<<day+1<<" "<<mounth<<" "<<year;
          }
    }
    return 0;
}