The first line of the input gives the number of test cases, $T$. $T$ test cases follow.
Each test case starts with a line consists of 3 integers $N$, $M$ and $X$, indicating the number of stations, the number of chat contents and the minute interval between Mr. Panda and God Sheep. Then $M$ lines follow, each consists of 4 integers $A$, $B$, $C$, $D$, indicating each chat content.
$1 \leq T \leq 30$
$1 \leq N, M \leq 2000$
$1 \leq X \leq 10^9$
$1 \leq A, B, C, D \leq N$
$A \leq B \leq A + 1$
$C \leq D \leq C + 1$