Artificial Neural Network
Time limit3sMemory limit1024 MB
Given a network of linear neurons and Q input vectors, compute the network's output for each input.
Problem
In 2020, the Seoul Metropolitan Office of Education designated Sunlin Internet High School as a high school specializing in artificial intelligence.
Jeong-hwi decided to write neural network problems to check whether his juniors had received good AI education over the past two years.
An artificial neural network is a net-shaped structure made of several artificial neurons. The -th artificial neuron has weights and a bias . When it receives inputs , it outputs the following value.
The figure below shows the structure of an artificial neuron.

For example, take a neuron with weights and bias . If the inputs are , the output is .
The neural network Jeong-hwi prepared has an input layer, a hidden layer, and an output layer.
The input layer consists of inputs , and the hidden layer consists of artificial neurons. The -th hidden neuron takes as inputs and computes its output. The output layer is a single artificial neuron. It takes the outputs of hidden neurons in that order as inputs and computes its output. For convenience, the output layer neuron is called the -th artificial neuron.
For example, suppose the weights are , the biases are , and the hidden neurons take the input layer values at positions as inputs. If the input is , the network can be drawn as in the figure below.

Given the structure of a neural network and its input data, write a program that computes the output of the network.
Input
The first line contains three integers , , and , separated by spaces. is the size of the input layer, is the number of hidden neurons, and is the number of times the output must be computed.
From the second line through the -th line, each line gives one hidden neuron in order. Each line contains the number of inputs , the input positions , the weights , and the bias , separated by spaces. (, , and the are distinct for each )
The next line gives the output neuron. It contains the weights and the bias , separated by spaces. ()
Each of the next lines contains one set of input data, which is integers . ()
All input numbers are integers.
Output
Print lines. Each line contains the answer for one input.
Hints
Python users are recommended to submit with PyPy.
The answer can exceed the range of a 32-bit integer.