#K66557. Event Attendance Conflict Checker

    ID: 32446 Type: Default 1000ms 256MiB

Event Attendance Conflict Checker

Event Attendance Conflict Checker

You are given several datasets, each representing a series of events. Every event is defined by its start time, end time, and a list of attendees. An attendee can attend all the events if and only if none of their events overlap in time. Two events overlap if the start time of one event is less than the end time of another event. Your task is to determine, for each dataset, whether all attendees can attend all the events they are required to attend without any conflicts.

Note: The time intervals are given in integers, and the comparison is done by checking the overlaps strictly. If an event's start time is equal to the previous event's end time, it is not considered as an overlap.

Input/Output is to be done using stdin and stdout.

inputFormat

The input begins with an integer T (1 ≤ T ≤ 100), representing the number of datasets. For each dataset, the first line contains an integer N (1 ≤ N ≤ 1000), denoting the number of events. Each of the following N lines describes an event and contains:

  • Two integers start and end (0 ≤ start < end ≤ 109), representing the start and end times.
  • An integer M (M ≥ 0) indicating the number of attendees for that event.
  • M integers (each between 1 and 109) denoting the attendee IDs.

Read the input from stdin.

outputFormat

For each dataset, output a single line with either Yes if it is possible for every attendee to attend all events without any time overlaps, or No if there is any conflict.

Write the output to stdout.

## sample
2
3
10 20 3 1 2 3
15 25 2 1 3
20 30 2 3 4
2
5 15 1 1
10 20 1 1
No

No

</p>