A problem that comes up fairly often during finals week is that a student is scheduled to take several different final exams at the same time. For some students this may actually be manageable: they hand in one exam an hour early and use that hour to take another. For the rest of us, though, it simply is not possible.
Such conflicts can be detected early and automatically. The default time of each course's final is announced well in advance, and the set of courses each student is enrolled in is known early too. So that overlap statistics can be gathered in the future, you get to write a small tool that reports how many students have overlapping final exams.
The first line contains the number of data sets $K \ge 1$. It is followed by $K$ data sets in the following form.
The first line of a data set contains two integers $m$ and $n$ ($1 \le m, n \le 1000$): $m$ is the number of courses offered and $n$ is the number of students.
The next $m$ lines each give a course's name together with the day and time of its final. A course name is a string of 4 upper-case letters (such as CSCI) followed by 3 digits (such as 402). The day is written in upper case as one of M, T, W, TH, or F. The exam time is given as hh:mm-hh:mm, the start and end times, where the hour hh is between 00 and 23 and the minute mm is between 00 and 59. Every final ends on the same day it starts. The fields are separated by a single space each.
The next $n$ lines each describe one student. Because only statistics matter, students are not named; each student is described by the list of courses he or she is taking. Each list is on one line and consists of 1 to 10 of the course identifiers above, separated by a single space each.
For each data set, first print Data Set x: on a line by itself, where $x$ is the data set's number. Then, on the next line, print the total number of students who have an overlap between two or more of their final exams. If one exam ends at exactly the time another starts, that does not count as an overlap.