#include<bits/stdc++.h>
using namespace std;
int main (){
int M,D;
cin>>M>>D;
if(M==1||M==3||M==5||M==7||M==8||M==10||M==12){
if(D+1>31){
if(M+1>12){
cout<<"1"<<" "<<"1"<<endl;return 0;
}
else{
cout<<M+1<<" "<<"1"<<endl;return 0;
}
}
else{
cout<<M<<" "<<D+1<<endl;return 0;
}
}
if(M=2){
if(D+1>28){
cout<<M+1<<" "<<"1"<<endl;return 0;
}
else{
cout<<M<<" "<<D+1<<endl;return 0;
}
}
if(M==4||M==6||M==9||M==11){
if(D+1>30){
cout<<M+1<<" "<<"1"<<endl;return 0;
}
else{
cout<<M<<" "<<D+1<<endl;return 0;
}
}
}