#C8672. Flight Service Query
Flight Service Query
Flight Service Query
You are given detailed information about a set of flights. Each flight has a unique flight ID along with a list of destination IDs it services. For each query consisting of a destination ID, your task is to identify all flight IDs that serve that destination.
For each queried destination, output the flight IDs in ascending order separated by a space. If no flight services a queried destination, print None
.
Formally, you are given an integer ( n ) (number of flights) followed by ( n ) lines where each line starts with a flight ID, followed by an integer ( k ) denoting the number of destinations for that flight, and then ( k ) destination IDs. After that, you are given an integer ( q ) (number of queries) followed by ( q ) destination IDs. Your task is to output the corresponding flight IDs for each query as described.
inputFormat
Input is read from standard input.
The first line contains an integer ( n ), the number of flights.
The next ( n ) lines each contain details of a flight: the first integer is the flight ID, followed by an integer ( k ) (number of destinations for that flight), and then ( k ) destination IDs.
The next line contains an integer ( q ), the number of queries.
The final line contains ( q ) integers representing the destination IDs to be queried.
outputFormat
For each query, print a line containing the sorted flight IDs that service the queried destination, separated by a space. If there is no flight servicing that destination, print 'None'.## sample
5
101 3 1 2 3
102 2 1 4
103 1 2
104 2 3 4
105 1 5
3
1 3 5
101 102
101 104
105
</p>