#K41127. Online Marketplace Query
Online Marketplace Query
Online Marketplace Query
You are given a collection of items from an online marketplace. Each item is described by an item ID, an item name (enclosed in single quotes), and one or more keywords which describe its attributes.
The input starts with two integers n and q denoting the number of items and the number of queries, respectively. Each of the next n lines contains the item information. Following that, there are q lines each containing a query keyword.
Your task is to, for each query, output a list of item IDs (in increasing order) whose associated keywords contain the given query keyword. If no items match a query, output a blank line for that query. Note that keyword matching is case-sensitive.
The sorted order of the item IDs is important.
Input Format (stdin): First line contains two integers n and q. The next n lines each contain an item's description. The following q lines each contain a query keyword.
Output Format (stdout): For each query, print a line with the matching item IDs in ascending order separated by a single space. If there are no matches, print an empty line.
inputFormat
The first line contains two integers n and q.
The next n lines each contain an item description in the format:
item_id 'item_name' keyword1 keyword2 ...
The last q lines each contain a single query keyword.
outputFormat
For each query, output a line containing the sorted item IDs whose keywords match the query keyword exactly, separated by spaces. If no item matches, output an empty line.
## sample3 2
1 'Laptop' electronics computer portable
2 'Headphones' audio music electronics
3 'Keyboard' computer accessories electronics
computer
music
1 3
2
</p>