Probable diagnosis#7269

Probable diagnosis

1 second
256 megabytes
Hard

As a course project Alex designs hospital information system. Now he needs to write a component which puts a tentative diagnosis based on statistical data.

The program is loaded with information about diseases and possible symptoms. For each disease the chance that the patient appears to have each symptom is known. Similar information is known for healthy people. Alex assumes, that each of the patients has no more than one disease, and if the disease (or its absence) is determined, the various symptoms will occur independently.

The program loads information about patients. For each particular patient it is known that some symptoms occur, and some do not, others have not been tested. We need to determine the possibility of this patient to be sick with every known disease.

Input

The first line contains two integers: and (1 \le N \le 200, 1 \le M \le 200).

The next line contains numbers — the probability that healthy person has corresponding symptom.

The following lines contain information about diseases. Each of them contains M + 1 numbers: the probability that a person is sick with this disease (sum of the probabilities of all the diseases is less than 100%), and the probability of occurrence of each symptom, if a person is sick with the disease.

The next line contains a single integer (1 \le K \le 200).

The following lines contain information about patients: each of them contains a string long, each of the symbols of which is +, if the patient appears to have the corresponding symptom, -, if it doesn't appear, or ?, if there is no detailed information about it.

All probabilities in the input file are specified in percentages, each value is a number from 0 to 100 with exactly two digits after the dot. It is guaranteed, that the combination of symptoms for each patient has a non-zero probability.

Output

Print strings — one for each patient. Each line should contain numbers — the probability, that a patient has a corresponding disease. Print the probability as floating point number from 0 to 1 with an absolute error not greater than 10^{-7}.

Examples

Example 1

Loading
Loading