#include <iostream>
#include "matrix.h"
#include "date.h"

using namespace std;

int main()
{
    date          d(2001,1,1);
    matrix<date>  md(52,7);

    for ( int i = 0; i < md.rows(); ++i )
        for ( int j = 0; j < md.cols(); ++j )
            md( i, j ) = d++;

    int week, day;
    while ( cin >> week >> day )
    {
        cout << md.at( --week, --day ) << endl;
    }
    return 0;
}