You lead an army to fight monsters in a world where the blood of monsters is composed of physical blood $hp_p$ and magical blood $hp_m$.
Your army has $n$ soldiers, the $i$-th soldier has $k_i$ attack methods, and the $j$-th attack method of the $i$th soldier causes $p_{ij}$ points of physical damage and $m_{ij}$ points of magic damage to the monster.
The total attack power of an army is the sum of the attack power of each soldier, and the attack power of each soldier is a weakly normalized linear combination of all attack methods of this soldier, i.e., the coefficients sum of the linear combination is less than or equal to 1. Formally, if the physical damage caused by a total attack of the army is $hurt_p$ and the magic damage is $hurt_m$, then
$$hurt_p = \sum\limits_{i=1}^{n}{\sum\limits_{j=1}^{k_i}{c_{ij}*p_{ij}}}$$
$$hurt_m = \sum\limits_{i=1}^{n}{\sum\limits_{j=1}^{k_i}{c_{ij}*m_{ij}}}$$
where $c_{ij}$ is the weight assigned by the $i$-th soldier to the $j$-th attack, satisfying: $\forall i:\sum\limits_{j=1}^{k_i} {c_{ij}} \leq 1$, $\forall c_{ij} \geq 0$.
Since you're competitive, you want to know if you can kill the monster in just $1$ attack. After your army fights the $r$-th monster, whether or not it can be killed by your army in a single attack, it will drop an attack method that will be gained by the $s_r$-th soldier.
During the expedition, you will encounter $q$ monsters in turn. For the $r$-th monster, it has five attributes $hp_{pr},hp_{mr},p_r,m_r,s_r$, which indicate the physical blood, magic blood, the physical damage and magic damage of the new attack method, the number of the soldier who gained the attack method after the battle.
To defeat a monster, you need to find an attack combination that makes the monster's physical and magic HP exactly 0.