There are multiple test cases.
Each case starts with a line containing two positive integers $n(n \leq 500)$ and $m(m \leq 10^4)$.
In the following $m$ lines, each line contains five positive integers $u, \; v, \; a, \; b, \; c$ $(1 \leq u, v \leq n, u \neq v, 1 \leq a, c \leq 4 \times 10 ^6, b = a / 4 + c / 3)$, denoting soldiers $u$ and $v$ have combination ability, guaranteed that the pair $(u,v)$ would not appear more than once.
It is guaranteed that the sum of $n$ in all test cases is no larger than $5 \times 10^3$, and the sum of $m$ in all test cases is no larger than $5 \times 10^4$.