Problem 105: Stop the Spungos

(U.M. ACM Runoffs 2001, problem 5)

Description

There are a large number of couterfeit tickets for the 2001 super bowl on the market. The organisers of the event will tell you their methods for detecting valid tickets if you'll automate the process for them.

Each ticket contains three pieces of information: The name of one of the teams, the name of the other team, and a serial number. Any ticket that conforms to all of those rules is considered valid. Any ticket that breaks any of those rules is rejected.

Input Format

There will be a number of lines of input, each line will contains exactly the information from one ticket. The last line in the input will contain just the three character sequence "END", which should not be processed as a ticket.

Output Format

For each input ticket, print a single line, stating "Ticket number NNN: good" if the ticket is accepted, or "Ticket number NNN: BAD!!!" if the ticket is rejected. NNN should be replaced by the number of the ticket in the input sequence (starting with 1), not the ticket's serial number.

Limits

No line of input will contain more than 1000 characters.

Sample Input

Rams~Broncos~000000000000000000000000000013
L.A. Bastards~Oakland Browns~000000000000000000000000002639
49ers~Mets~132613261326391326393939132652
Jets~Sharks~001313131326262626131313262613
Cowboys~Spungos~001313131326262626131313262613
Dallas Cowboys~Boston Spungos~001313131326262626131313262613
Atlanta Rednecks~Dallas Gayboys~001313131326262626131313262614
Bubs Team~Knicks~1313131313131313131313131313
Team A~Team B~596349123761250925101011010178
Cowboys~Cowboys~001313131326262626131313262613
Team A~Team B~596349123761250925101011010178~Drink Coke!
END

Sample Output

Ticket number 1: good
Ticket number 2: good
Ticket number 3: good
Ticket number 4: good
Ticket number 5: BAD!!!
Ticket number 6: good
Ticket number 7: BAD!!!
Ticket number 8: BAD!!!
Ticket number 9: good
Ticket number 10: BAD!!!
Ticket number 11: BAD!!!

Explanation of Sample

Ticket 5: "Spungos" is not a proper team.
Ticket 6: "Boston Spungos" is OK, only the "Spungos" are forbidden.
Ticket 7: Serial number not divisible by 13.
Ticket 8: Serial number not 30 digits.
Ticket 9: A big number that's divisible by 13. That will make testing easier for you.
Ticket 10: The Cowboys are playing with themselves.
Ticket 11: Not just the three components.

End of Problem