Little Q and Little T are playing a guessing game. In each round, Little T comes up with $$$n$$$ positive integers $$$x_1,x_2,\dots,x_n$$$ and writes down them on the paper. He should ensure these integers are all in the range $$$[1,m]$$$, and he is not allowed to change them during the game. Then Little Q can ask as many questions as he likes. There are two types of questions Little Q can ask:
For each question, Little T will always answer it honestly in the form "It's in the range $$$[l,r]$$$."
Now Little Q has asked $$$q$$$ questions, he still can't figure out the value of $$$x_1,x_2,\dots,x_n$$$, can you please tell him the minimum possible value of $$$x_1+x_2+\dots+x_n$$$ and the maximum possible value of $$$x_1+x_2+\dots+x_n$$$?
The first line contains a single integer $$$T$$$ ($$$1 \leq T \leq 5$$$), the number of test cases. For each test case:
The first line contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \leq n \leq 8$$$, $$$1\leq m\leq 1\,000\,000$$$, $$$1\leq q\leq 500$$$), denoting the number of numbers, the upper bound of numbers and the number of questions.
Each of the following $$$q$$$ lines starts with two integers $$$op_i$$$ and $$$k_i$$$ ($$$1\leq op_i\leq 2,1\leq k_i\leq n$$$), followed by $$$k_i$$$ distinct integers $$$p_{i,1},p_{i,2},\dots,p_{i,k_i}$$$ ($$$1\leq p_{i,j}\leq n$$$), ending with two integers $$$l_i$$$ and $$$r_i$$$ ($$$1\leq l_i\leq r_i\leq m$$$), describing each question and the answer:
For each test case, output a single line containing two integers $$$\min\{sum\}$$$ and $$$\max\{sum\}$$$, denoting the minimum possible value of $$$x_1+x_2+\dots+x_n$$$ and the maximum possible value of $$$x_1+x_2+\dots+x_n$$$.
It is guaranteed that the answer always exists.
23 10 11 1 1 5 55 100 21 3 2 3 4 7 92 3 2 3 4 7 9
7 25 23 227