#C7443. Gemstone Retrieval

    ID: 51315 Type: Default 1000ms 256MiB

Gemstone Retrieval

Gemstone Retrieval

In this problem, you are given a list of gemstones, where each gemstone is represented by its weight (in carats), clarity, and color value. You will also be provided with several queries. Each query specifies a property (either 'weight', 'clarity', or 'color') and a value, and you must count the number of gemstones that exactly match the query criteria.

For instance, if a query is given as (\texttt{weight}\ 10), you need to count all gemstones whose weight equals 10. Similarly, a query (\texttt{clarity}\ VVS1) demands counting gemstones with clarity equal to "VVS1".

Your task is to process the input from standard input (stdin) and print the result for each query on a new line to standard output (stdout).

inputFormat

The input begins with an integer (n) representing the number of gemstones. The following (n) lines each contain the description of a gemstone in the format:

weight clarity color

Here, (\texttt{weight}) and (\texttt{color}) are integers, and (\texttt{clarity}) is a string.

After the gemstone descriptions, there is an integer (q) specifying the number of queries. Each of the next (q) lines contains a query in the format:

query_type query_value

The (\texttt{query_type}) is one of the three strings: "weight", "clarity", or "color". For queries of type "weight" and "color", (\texttt{query_value}) will be an integer, while for queries of type "clarity", it will be a string.

outputFormat

For each query, output a single integer on a new line, indicating the number of gemstones that match the given query.## sample

5
10 VVS1 5
15 VS2 7
8 SI1 2
12 VVS1 4
20 VS1 8
3
weight 10
weight 15
weight 8
1

1 1

</p>