#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,y,r,2n,2y,2r,c=0;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
cin>>n>>y>>r;
if(n%4==0&&n%100!=0||n%400==0)
{
a[2]=28;
c=366;
}
else
{
a[2]=29;
c=365;
}
r++;
if(r>a[y])
{
r=1;
y++;
}
if(y>12)
{
y=1;
n++;
}
cout<<n<<" "<<y<<" "<<r<<" ";
return 0;
}