It's time for the first game of the global edition of the Squid Games.
The game is played in a tower with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$, each floor containing $$$k$$$ rooms numbered from $$$1$$$ to $$$k$$$. There are $$$m$$$ stairs; the $$$i$$$-th stair connects room $$$u_i$$$ on floor $$$f_i$$$ with room $$$v_i$$$ on floor $$$f_i + 1$$$.
There are $$$2\cdot10^9$$$ players invited to play the game. At the beginning, each of the $$$2 \cdot 10^9$$$ players must choose any room on the first floor. The game lasts for $$$n$$$ turns. In turn $$$t$$$ ($$$1 \le t \le n$$$), the following actions occur in order:
Player 456 wants to maximize the number of players who survive. For each turn $$$t$$$, compute the maximum number of players that can be alive at the end of that turn, assuming optimal choices for the initial distribution and movements. Note that for each $$$t$$$, these values are calculated independently.
The first line contains three integers $$$n$$$, $$$k$$$, and $$$m$$$ ($$$1 \le n \le 1000$$$, $$$1 \le k \le 15$$$, $$$0 \le m \le (n-1) \cdot k^2$$$).
The next $$$n$$$ lines each contain $$$k$$$ integers $$$C_{i,1}, C_{i,2}, \dots, C_{i,k}$$$ ($$$0 \le C_{i,j} \le 10^8$$$), representing the capacity of each room.
Then $$$m$$$ lines follow. Each contains three integers $$$f_i$$$, $$$u_i$$$, and $$$v_i$$$ — describing a stair from room $$$u_i$$$ on floor $$$f_i$$$ to room $$$v_i$$$ on floor $$$f_i+1$$$.
Print a single line with $$$n$$$ integers — the answer for each turn.
2 2 13 74 21 1 2
10 2
3 3 58 2 43 4 84 5 01 1 11 2 21 3 32 1 12 2 2
14 9 5
| Name |
|---|


