The first line contains a single integer $T$ ($1 \leq T \leq 10$), the number of test cases. For each test case:
The first line contains two integers $n$ and $m$ ($2 \leq n \leq 1\,000$, $n-1\leq m\leq 200\,000$), denoting the number of cities and the number of candidate roads.
Each of the following $m$ lines contains four integers $u_i,v_i,c_i$ and $d_i$ ($1 \leq u_i,v_i \leq n$, $u_i\neq v_i$, $1\leq d_i\leq c_i\leq 1\,000$), describing a candidate road.