The first line contains an integer CA which indicates the number of test cases.
Then CA cases follow.
Each case contains two parts,the students' courses information and the query.
In the first part ,first there is an integer N(N<200) which means the number of the student,and then comes the N students’ courses information.
A student's courses information is in this format:
line1: name K
line2: day1 b1 e1
.....
lineK+1: dayK bK eK
The first line of a student's courses infomation contains his name(less than 20 characters and in lowercase) and the number(K,K<1000) of his courses . Then next K lines describe his courses. Each Line contain three integers indicate the day of a week( 1 <= day <= 7 means Monday to Sunday ), the begin time and the end time of the course.
To make the problem easier,the begin time and the end time will be in the range from 1 to 11 .(Because in HDU,there is 11 classes one day).
In the query part , first there is an integer Q which means the query number,and then Q lines follow.
A query contains three integers which means the day ,the begin time and the end time of the spring-outing.And the time is described as the courses.
Notice,everyone may have more than one course at the same time for some special reasons.