Busy Beaver lived on an unpainted sidewalk consisting of $$$N$$$ individual tiles numbered $$$1,2,\dots,N$$$ from left to right. The tiles all start with the factory-standard color $$$0$$$, but Busy Beaver is looking to change that! Over several days of painting, Busy Beaver aims to repaint the entire sidewalk.
Specifically, Busy Beaver wrote down a list of $$$Q$$$ plans, the $$$i$$$-th of which states that on day $$$d_i$$$ ($$$0 \le d_i \le 2^K-1$$$), Busy Beaver will repaint all tiles in the range $$$[x_i, y_i]$$$ with color $$$c_i$$$, overwriting their previous colors. Busy Beaver has at most one painting plan scheduled for each day, and he is interested in the sum of the final colors of all tiles after all the repaintings.
Unbeknownst to Busy Beaver, he is, in fact, the first Beaver to live in a Quantum Computer! This unfortunately means that the universe does not operate as he thinks it does. During the night, while no one is watching, the qubits undergo a random transformation: an integer $$$z$$$ between $$$0$$$ and $$$2^K - 1$$$ is selected, and every plan originally scheduled for day $$$i$$$ is instead moved to day $$$i \oplus z$$$, where $$$\oplus$$$ denotes bitwise XOR.
For a given $$$z$$$, the plans are then executed in increasing order of their (shifted) day, and each repaint operation overwrites the colors of the tiles between $$$x_i$$$ and $$$y_i$$$. Let $$$F(z)$$$ be the sum of the final colors of all tiles after applying the plans with shift $$$z$$$.
Compute $$${\large \sum_{z=0}^{2^K - 1}} F(z)$$$. Since the answer may be enormous, output it modulo $$$10^9+7$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1\leq T\leq 150$$$). The description of the test cases follows.
The first line of each test case contains three integers $$$N$$$, $$$K$$$, and $$$Q$$$ ($$$1\leq N\leq 2\cdot10^5$$$, $$$0\leq K\leq60$$$, $$$1\leq Q\leq \min(2^K,2\cdot 10^5)$$$).
The $$$i$$$-th of the next $$$Q$$$ lines contains four integers $$$d_i$$$, $$$x_i$$$, $$$y_i$$$, and $$$c_i$$$ ($$$0\leq d_i \lt 2^K$$$, $$$1\leq x_i\leq y_i\leq N$$$, $$$0\leq c_i\leq10^9$$$).
It is guaranteed that the sum of $$$N$$$ across all test cases is at most $$$4\cdot10^5$$$, the sum of $$$Q$$$ across all test cases is at most $$$4\cdot10^5$$$, and all $$$d_i$$$'s within a test case are distinct.
For each test case, output one integer on its own line: the sum of the answers to Busy Beaver's original question over all $$$2^K$$$ possible shifts, modulo $$$10^9+7$$$.
There are five subtasks for this problem.
36 4 66 3 5 412 2 2 34 1 4 25 3 3 414 1 1 313 1 6 46 4 44 1 2 03 2 6 42 2 2 25 3 5 04 4 68 2 4 211 1 3 29 3 4 410 3 3 22 3 4 33 1 4 5
332184220
35 4 49 1 2 212 1 3 110 4 5 314 1 5 46 4 45 2 4 314 5 6 210 3 6 31 4 6 56 4 511 2 4 513 1 2 414 4 6 510 1 6 315 2 6 0
224272276
| Name |
|---|


