//#include <iostream>
//
//using namespace std;
//
//int main()
//{
// int x = 100;
// cout << "Hello world!" << endl;
// cout << "hee" << x << "asdsad" << endl;
// // 2 << 1 : 4
// return 0;
//}
//#include<stdio.h>
//
//int main() {
// printf("HELLO WORLD");
//
// return 0;
//}
// escape sequence
/*
#include<iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
}
*/
/*
#include<iostream>
using namespace std;
int main()
{
cout << "Hello"<< endl;
cout << "World"<<endl;
return 0;
}
*/
/*
#include<iostream>
using namespace std;
int main()
{
cout<<"\"Hello World\""<< endl;
return 0;
}
*/
/*
#include<iostream>
using namespace std;
int main()
{
cout<<"\"C:\\Download\\hello.cpp\""<<endl;
return 0;
}
*/
// operator
/*
#include<iostream>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
// + - * / %
// 5 / 2 = 2(몫)
// %: rotate
printf("%.2f ", 1.0 / 2);
cout << x+y << " ";
cout << "Hello" << endl;
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
long long int x,y;
cin>>x>>y;
cout<<x+y<<endl;
return 0;
}
// if - condition
// loop
// array
// function
// class
// constructor / destructor
// Inharitance
// overloading / overriding
// pointer
//
*/
/*
#include<iostream>
using namespace std;
int main()
{
char x;
cin >> x;
cout << (char)(x+1) <<endl;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a>>b;
cout << (a%b) << endl;
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >>a>>b;
cout << a+b << endl;
cout << a-b << endl;
cout << a*b << endl;
cout << a/b << endl;
cout << a%b << endl;
printf("%.2lf", (double)a/b);
return 0;
}
*/
/*
#include<iostream>
using namespace std;
int main() {
int x, y;
}
*/
// && || !
/*
A B | && || | !
0 0 | 0 0 | 1
0 1 | 0 1 | 0
1 0 | 0 1 | 0
1 1 | 1 1 | 0
(a&&b)
(!a&&b) || (a&&!b)
*/
/*
#include <iostream>
using namespace std;
int main()
{
int x;
cin >>x;
cout << !x << endl;
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >>a>>b;
cout << (a&&b) <<endl;
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >>a>>b;
cout << (a||b) <<endl;
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << ((a&&!b)||(!a&&b));
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << ((a&&b)||(!a&&!b));
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << !(a||b) << endl;
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
if(n > 100) {
cout << "Big!" << endl;
}
else if() {
if() {
}
else {
}
}
else if() {
*/
/*
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin >> a >> b >> c;
if (a+b<=c){
cout << "삼각형아님";
}
else if(a==b&&b==c){
cout << "정삼각형";
}
else if (a==b||b==c){
cout << "이등변삼각형";
}
else if (a*a+b*b==c*c){
cout << "직각삼각형";
}
else{
cout <<"삼각형";
}
return 0;
}
*/
/*
#include <iostream>
using namespace std;
int main()
{
int n,a,b;
cin >>n;
a = n/10;
b = n%10;
n = (b*10+a)*2%100;
cout << n <<endl;
if(n<=50){
cout<<"GOOD";
}
else{
cout<<"OH MY GOD" <<endl;
}
}
*/
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
if(b>=30) {
cout << a << " " << (b-30);
}
else {
if(a ==0) {
cout << (23) << " " << (b+30);
}
else {
cout << (a-1) << " " << (b+30);
}
}
return 0;
}
/*
if(a==0) {
a = 23;
b+=30;
cout << a<< " "<< b;
}
else {
if (b>=30){
cout << a<<" "<< (b-30);
}
else{
a-=1;
b+=30;
cout << a<< " "<< b;
}
}
*/