#P4642. [BJWC2008] 方程

[BJWC2008] 方程

Description

You are given 3×N3 \times N positive integers:

A1,A2...AnA_1, A_2...A_n

B1,B2...BnB_1, B_2...B_n

C1,C2...CnC_1, C_2...C_n

You are also given MM pairs of positive integers Si,TiS_i, T_i. For each pair Si,TiS_i, T_i, find a set of non-negative real solutions to the following system of equations:

A1X1+A2X2+...+AnXn=SiA_1X_1 + A_2X_2 + ... + A_nX_n = S_i

B1X1+B2X2+...+BnXn=TiB_1X_1 + B_2X_2 + ... + B_nX_n = T_i

such that C1X1+C2X2+...+CnXnC_1X_1 + C_2X_2 + ... + C_nX_n is maximized.

Input Format

The first line contains two integers N,MN, M.

The next NN lines each contain three positive integers Ai,Bi,CiA_i, B_i, C_i.

Constraints: N105N \leq 10^5, M104M \leq 10^4.

1Ai,Bi,Ci,Si,Ti10000001 \le A_i, B_i, C_i, S_i, T_i \le 1000000.

Output Format

Output MM lines. The ii-th line corresponds to Si,TiS_i, T_i.

If the system has no solution, output IMPOSSIBLE.

Otherwise, output a real number rounded to five decimal places, representing the corresponding maximum value.

1 2
100 100 10
3 3
99 100
0.30000
IMPOSSIBLE

Hint

Translated by ChatGPT 5