Distributing budgeted money with limited resources and many constraints is a hard problem. A budget plan consists of t topics; i-th topic consists of n_i items. For each topic, the optimal relative money distribution is known. The optimal relative distribution for the topic i is a list of real numbers p_i,j, where ∑_j=1n_ip_i,j=1.
Let's denote the amount of money assigned to j-th item of the topic i as c_i,j; the total amount of money for the topic is C_i=∑_j=1n_ic_i,j. A non-optimality of the plan for the topic i is defined as ∑_j=1n_iC_ic_i,j−p_i,j. Informally, the non-optimality is the total difference between the optimal and the actual ratios of money assigned to all the items in the topic. The total plan non-optimality is the sum of non-optimalities of all t topics. Your task is to minimize the total plan non-optimality.
However, the exact amount of money available is not known yet. j-th item of i-th topic already has c^_i,j dollars assigned to it and they cannot be taken back. Also, there are q possible values of the extra unassigned amounts of money available x_k. For each of them, you need to calculate the minimal possible total non-optimality among all ways to distribute this extra money. You don't need to assign an integer amount of money to an item, any real number is possible, but all the extra money must be distributed among all the items in addition to c^_i,j already assigned. Formally, for each value of extra money x_k you'll need to find its distribution d_i,j such that d_i,j≥0 and ∑_i=1t∑_j=1n_id_i,j=x_k, giving the resulting budget assignments c_i,j=c^_i,j+d_i,j that minimize the total plan non-optimality.
The first line contains two integers t (1≤t≤5⋅104) and q (1≤q≤3⋅105) --- the number of topics in the budget and the number of possible amounts of extra money.
The next t lines contain descriptions of topics. Each line starts with an integer n_i (2≤n_i≤5) --- the number of items in i-th topic; it is followed by n_i integers c^_i,j (0≤c^_i,j≤105; for any i, at least one of c^_i,j>0) --- the amount of money already assigned to j-th item in i-th topic; they are followed by n_i integers p′_i,j (1≤p′_i,j≤1000) --- they determine the values of p_i,j as p_i,j=p′_i,j/∑_j=1n_ip′_i,j with ∑_j=1n_ip_i,j=1.
The next line contains q integers x_k (0≤x_k≤1012) --- k-th possible amount of extra money.
Output q real numbers --- the minimal possible non-optimality for the corresponding amount of extra money x_k. An absolute or a relative error of the answer must not exceed 10−6.