#C12067. Sneaker Acquisition Query

    ID: 41453 Type: Default 1000ms 256MiB

Sneaker Acquisition Query

Sneaker Acquisition Query

You are given two sets of data. The first set is a list of sneakers, each defined by a brand, a model, and an acquisition year. The sneakers are given in the order they were acquired. The second set is a list of queries; each query consists of a brand, a model, and an integer k. For each query, you are required to determine and output the acquisition year of the k-th occurrence of the sneaker with the queried brand and model in the given list.

The answer for a query with parameters (brand, model, k) is the acquisition year corresponding to the k-th appearance of that sneaker. Formally, if you denote by \(L(brand, model)\) the list of acquisition years for sneakers matching the brand and model in the order they appear, the answer is:

[ \text{answer} = L(brand, model)[k-1] ]

You need to read input from standard input (stdin) and output your answer to standard output (stdout).

inputFormat

The first line contains an integer n (the number of sneakers). The next n lines each contain a sneaker's information: a string brand, a string model, and an integer year, separated by spaces.

The next line contains an integer q (the number of queries). The following q lines each contain a query with a brand, a model, and an integer k, separated by spaces.

outputFormat

For each query, output the acquisition year on a separate line to standard output (stdout).

## sample
5
Nike AirMax 2019
Adidas Ultraboost 2020
Nike AirMax 2019
Adidas Ultraboost 2018
Nike Revolution 2022
4
Nike AirMax 1
Adidas Ultraboost 2
Nike Revolution 1
Nike AirMax 2
2019

2018 2022 2019

</p>