#include <iostream>

bool isLeapYear( const uint16_t year )
{
  return ( (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0) );
}

uint8_t getDaysInMonth( const uint8_t month, const uint16_t year )
{
  if ( month == 2 )  
    return isLeapYear( year ) ? 29 : 28;
    
  else if ( month == 4 || month == 6 || month == 9 || month == 11 )  
      return 30;
      
  return 31;
}

uint16_t getDaysInYear( const uint16_t year )
{
  return isLeapYear( year ) ? 366 : 365;
}


int main()
{
	int startYear = 1998;
	int daysOffset = 4003;
	
	
	int d = daysOffset+1;
	int m = 1;
	int y = startYear;
	
	while ( d > getDaysInYear( y ) )
		d -= getDaysInYear( y++ );
	
	while ( d > getDaysInMonth( m, y ) )
		d -= getDaysInMonth( m++, y );


	printf( "%d %d %d", d, m, y );


	return 0;
}