// Arup Guha
// 8/24/2021
// Alternate Solution to 2021 UCF Qualifying Round Problem: Cat's Age

#include <stdio.h>

int convertToMonths(int years, int months);

int main(void) {

    // Read in the years and months for the cat.
    int years, months;
    scanf("%d%d", &years, &months);

    // This to human months.
    int totalMonths = convertToMonths(years, months);

    // Present the answer by using div and mod 12.
    printf("%d %d\n", totalMonths/12, totalMonths%12);
    return 0;
}

// Returns the total number of human months (years, months) for a cat translates to.
int convertToMonths(int years, int months) {

    // First special case.
    if (years == 0) return 15*months;

    // Second special case.
    if (years == 1) return 15*12 + 9*months;

    // A general formula works here. Add year 1, year 2, rest of the complete years, then the months.
    return 15*12 + 9*12 + (years-2)*4*12 + 4*months;
}
