#include<stdio.h>
struct date{
int year;
int month;
int day;
};
int numbers_of_month(struct date d){
int number[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if((d.year%4==0&&d.year%100!=0)||(d.year%400==0))
number[1]=29;
return number[d.month-1];
}
int numbers_of_last_month(struct date d){
int number[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if((d.year%4==0&&d.year%100!=0)||(d.year%400==0))
number[1]=29;
return number[d.month-1-1];
}
int main(){
struct date today,tomorrow,yesterday;
scanf("%d %d %d",&today.year,&today.month,&today.day);
if(today.day==numbers_of_month(today)){
if(today.month==12) {
tomorrow.year=today.year+1;
tomorrow.month=1;
tomorrow.day=1;
}
else {
tomorrow.year=today.year;
tomorrow.month=today.month+1;
tomorrow.day=1;
}
}
else{
tomorrow.year=today.year;
tomorrow.month=today.month;
tomorrow.day=today.day+1;
}
if(today.day==1){
if(today.month==1) {
yesterday.year=today.year-1;
yesterday.month=12;
yesterday.day=31;
}
else {
yesterday.year=today.year;
yesterday.month=today.month-1;
yesterday.day=numbers_of_last_month(today);
}
}
else{
yesterday.year=today.year;
yesterday.month=today.month;
yesterday.day=today.day-1;
} printf("%d %d %d\n",yesterday.year,yesterday.month,yesterday.day);
printf("%d %d %d",tomorrow.year,tomorrow.month,tomorrow.day);
return 0;
}