PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000059. Bữa điểm tâm dim sum (Let's Yum Cha!)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bữa điểm tâm dim sum (Let's Yum Cha!)

Let's Yum Cha!

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

You and NN friends go to a dim sum restaurant. There are P=N+1P=N+1 people and KK types of dishes. Each type has a price cic_i and each person assigns an integer favour score between 00 and 1010.

Ordering one plate of type ii adds the sum of all PP favour scores for that type to the group's total favour value. Ordering two plates doubles its contribution. Maximize the mean favour value, namely the total favour over all ordered plates divided by PP.

No type may be ordered more than twice, no more than 2P2P plates may be ordered in total, and each person pays at most xx. The group therefore has a total payment limit of PxPx. In addition to the dishes, every person pays a fixed tea charge of TT. A service charge equal to 10% of the combined dish prices and tea charges, rounded up using the ceiling function (an already integer charge stays unchanged), is added to the bill.

Choose the number of plates of each type to maximize the mean favour while respecting every constraint. You need not use the entire budget or the entire plate allowance.

Input

The first line contains N,x,T,KN,x,T,K. Each of the next KK lines starts with dish price cic_i followed by exactly P=N+1P=N+1 favour scores, one for you and one for each of your NN friends.

Output

Print the optimal mean favour value with exactly two digits after the decimal point. Test data guarantees at least one affordable nonempty selection with positive favour.

Subtasks

  • Subtask 1 (20 points): 1≤N≤31\le N\le3, 1≤x≤201\le x\le20, 0≤T≤50\le T\le5, 1≤K≤121\le K\le12, 1≤ci≤1001\le c_i\le100 and 0≤fij≤100\le f_{ij}\le10 for all dishes and people; at least one dish has positive total favour and satisfies 11(T(N+1)+ci)≤10x(N+1)11(T(N+1)+c_i)\le10x(N+1).

  • Subtask 2 (30 points): 1≤N≤71\le N\le7, 1≤x≤601\le x\le60, 0≤T≤120\le T\le12, 1≤K≤401\le K\le40, 1≤ci≤1001\le c_i\le100 and 0≤fij≤100\le f_{ij}\le10 for all i,ji,j; at least one positive-favour dish meets 11(T(N+1)+ci)≤10x(N+1)11(T(N+1)+c_i)\le10x(N+1).

  • Subtask 3 (50 points): 1≤N≤101\le N\le10, 1≤x≤1001\le x\le100, 0≤T≤200\le T\le20, 1≤K≤1001\le K\le100, 1≤ci≤1001\le c_i\le100 and 0≤fij≤100\le f_{ij}\le10 for all i,ji,j; at least one positive-favour dish meets 11(T(N+1)+ci)≤10x(N+1)11(T(N+1)+c_i)\le10x(N+1).

Examples

Input


3 10 5 2
6 7 5 6 9
10 9 10 10 8

Output


16.00

Explanation

There are P=4P=4 people, so the total budget is 4040 and the tea charge is 4⋅5=204\cdot5=20. Dish 1 costs 66 and contributes 7+5+6+9=277+5+6+9=27 favour points. Dish 2 costs 1010 and contributes 9+10+10+8=379+10+10+8=37. Ordering one of each costs 6+10+20=366+10+20=36 before service; the service charge is ⌈36/10⌉=4\lceil36/10\rceil=4, so the bill is exactly 4040. The favour sum is 6464, yielding an average of 16.00. Two plates of dish 2 would cost 4444 including tea and service, exceeding the budget.