Given a string in the format 'MM-DD' where any number of 'M's or 'D's can be substituted with 'X', return the latest possible valid date within the calendar year; if invalid, return 'xx-xx'.
Implement latest_valid_date(date), which accepts and returns strings. The input must contain exactly five characters in MM-DD format, with digits or X in the month and day positions. Treat dates using the standard calendar, and return the result as MM-DD.
def latest_valid_date(date):