The first line contains the number of scenarios.
Every scenario contains a single date on a line by itself. A date consists of three parts: A day, a month, and a year given in any order, separated either by exactly two identical delimiters, or not separated by delimiters at all. Delimiters can be slashes '/', backslashes '\', hyphens '-', dots '.', or commas ','. The day and month are represented by a single digit, or by two digits, the first of which can be a leading zero. Valid years are in the range 1700 . . . 2299; either all four digits are given, or just the last two that specify the year relative to the century. In the latter case, a leading zero may be omitted.
Dates are considered illegal if no valid interpretation exists. More precisely, a date is illegal if no classification of the digits as day, month, and year results in a valid date in the range January 1, 1700, to December 31, 2299. However, you can be sure that all dates given contain 3 to 8 digits, and no other characters except for maybe the two delimiters.
Remember that February 29 is a valid date for leap-years only. A year is a leap-year if and only if either its number is divisible by four, but not by one hundred, or if its number is divisible by four hundred. So, in particular, 2000 is a leap-year, while 1700, 1800, 1900, 2100, or 2200 are not.