A company wants to finish m projects this week. To do that it can hire at most n outside workers from an employment agency, each on a one week contract.
One outside worker is paid salary euros. If the project that the worker was put on does not finish in time, the company pays that worker nothing.
For every project the company knows from experience the probability that the project finishes within the week, as a function of how many workers are on it. The probabilities are given as percentages pij, where i (1≤i≤m) is the project number and j is the number of workers on it. When nobody works on project i, the probability pi0 is 0 percent.
If project i finishes within the week, the company earns reward(i) euros. If it misses the deadline, the company pays a fine of punishment(i) euros.
Let p (0<p<1) be the probability that a job finishes in time, let E1 be the profit in that case, and let E2 be the (negative) profit when the job is late. The expected profit for that job is p×E1+(1−p)×E2.
The company decides how many outside workers to hire and how to spread them over the projects so that the total expected profit at the end of the week is as large as possible. The optimal number of workers is the total number of people needed to reach that maximal expected profit. Compute that number. At most n people are available, and a hired person works on exactly one project, so the total is the sum of the workers assigned to the projects.
The first line contains the number of test cases. Each test case has this format.
Print two lines for every test case.