#C11029. Catalog Artifacts
Catalog Artifacts
Catalog Artifacts
You are given a catalog of artifacts where each artifact is associated with a category. You will be given n artifacts and q queries. Each artifact has a name and a category. For each query, you are to retrieve all artifact names that belong to the queried category, preserving the order in which they were added.
If a queried category has no artifacts, print None
.
The input format is as follows:
- The first line contains two integers, \(n\) and \(q\), where \(n\) is the number of artifacts and \(q\) is the number of queries.
- The following \(n\) lines each contain two strings: the artifact name and its category.
- The next \(q\) lines each contain one string representing a category query.
The output should consist of \(q\) lines. Each line corresponds to a query and contains a space-separated list of artifact names that belong to the queried category, or None
if no artifact is found.
inputFormat
The input is given via standard input (stdin) and is described below:
- The first line contains two integers \(n\) and \(q\) separated by a space.
- The next \(n\) lines each contain two space-separated strings: the artifact name and its category.
- The following \(q\) lines each contain a single string representing a query.
outputFormat
For each query, output a single line. If there are artifacts for the queried category, print their names separated by a single space in the order they were added. Otherwise, print None
.
The output is to be printed to standard output (stdout).
## sample5 3
artifact1 category1
artifact2 category2
artifact3 category1
artifact4 category3
artifact5 category2
category1
category2
category4
artifact1 artifact3
artifact2 artifact5
None
</p>