#K7096. Supplier Product Pricing Query
Supplier Product Pricing Query
Supplier Product Pricing Query
You are given information about a set of suppliers and their products. Each supplier is associated with a unique supplier code and supplies a number of products. For each product, a product code and a corresponding price is given.
After reading the supplier data, you need to process several queries. Each query asks for the price at which a specific supplier offers a given product. If the supplier does not offer that product, output NOT AVAILABLE
.
The supplier data is provided in the following format:
For each supplier, the first line contains the supplier code and an integer m indicating the number of products supplied. The following m lines each contain a product code and its price.
After the supplier data, q queries follow, each on a new line; each query consists of a product code and a supplier code.
Input constraints: All numbers are integers. If a product is not found for a given supplier, output NOT AVAILABLE
exactly.
inputFormat
The input is read from stdin and has the following structure:
- The first line contains two integers n and q, where n is the number of suppliers and q is the number of queries.
- The next set of lines describe the supplier data. For each supplier, there is a line containing two integers: the supplier code and an integer m (the number of products for that supplier). This is followed by m lines, each with two integers: a product code and its price.
- After the supplier information, there are q lines. Each line contains two integers: a product code and a supplier code, representing a query.
outputFormat
For each query, output the price at which the supplier offers the product on a separate line. If the supplier does not provide that product, output NOT AVAILABLE
.
The output should be written to stdout.
## sample2 3
1 2
1002 150
1003 200
2 3
1001 300
1002 250
1003 350
1002 1
1003 1
1001 2
150
200
300
</p>