#C1705. Warehouse Random Box Picker

    ID: 44940 Type: Default 1000ms 256MiB

Warehouse Random Box Picker

Warehouse Random Box Picker

You are given a warehouse that consists of several shelves. Each shelf contains a certain number of boxes and each box holds a fixed number of items. You are required to initialize the warehouse with the given shelf configurations and then simulate a sequence of random box picks.

The warehouse is represented as a collection of boxes. For each shelf, you are given two integers \(s_i\) and \(b_i\), where \(s_i\) is the number of boxes on that shelf and \(b_i\) is the number of items contained in each box on that shelf. After initializing the warehouse, you will then perform a series of queries. In each query, you must pick one box uniformly at random from the warehouse and output the number of items in that box.

If the warehouse is empty, you should output an error message: "The warehouse is empty." and terminate the program without processing further queries.

Note: To ensure that the output is deterministic for evaluation purposes, you must initialize the random number generator with a seed of 42 before processing any picks.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. An integer n, representing the number of shelf configuration entries.
  2. n lines follow. Each line contains two space-separated integers \(s_i\) and \(b_i\), where \(s_i\) is the number of boxes on the i-th shelf and \(b_i\) is the number of items in each box.
  3. An integer Q representing the number of random box pick queries.

outputFormat

For each query, output a single line containing the number of items in the randomly picked box. If the warehouse is empty (i.e., no boxes are available), output "The warehouse is empty." and do not process further queries.

## sample
3
2 5
3 7
1 10
5
7

5 5 5 7

</p>