| UDESC Selection Contest 2026-1 |
|---|
| Finished |
Zapi is getting into the spirit of the Pangea World Cup, the biggest and best dinobol tournament in the entire Zapverse.
One tradition of this event is trying to complete the tournament's sticker album, which has a space reserved for each participating dinosaur. Zapi knows that the Pangea World Cup features $$$N$$$ players, numbered from $$$0$$$ to $$$N-1$$$, and that the only store selling sticker packs belongs to his good friend Coelho.
Coelho's store has a peculiarity: whenever someone wants to buy a pack, Coelho selects $$$K$$$ packs, and the person can choose exactly one of them to open.
Some details about the packs:
As a true World Cup fanatic, Zapi decided to make exactly $$$2^N$$$ purchases.
On the $$$i$$$-th purchase, Zapi's options are represented by a list of $$$K$$$ integers
$$$$$$ a_{i,0}, a_{i,1}, \dots, a_{i,K-1} $$$$$$
where $$$a_{i,j}$$$ represents the $$$j$$$-th pack available in the $$$i$$$-th purchase.
After all purchases, Zapi's album will contain all the stickers that appeared in at least one of the chosen packs. Two albums are considered different if the sets of stickers they contain are different.
For each possible set of stickers, represented by an integer $$$i$$$ ($$$0 \le i \lt 2^N$$$), define $$$F_i$$$ as the number of different ways to obtain exactly the album corresponding to $$$i$$$.
Your task is to calculate
$$$$$$ \bigoplus_{i=0}^{2^N-1} F_i, $$$$$$
where $$$\oplus$$$ represents the bitwise XOR operation.
Since numbers behave differently in the Zapverse, each value $$$F_i$$$ must be considered modulo zap, where zap $$$= 998244353$$$ in the Zapverse.
Note: Apply the modulo operation only to the values $$$F_i$$$. The final result of the XOR operation should not be calculated modulo zap.
The first line of the input consists of $$$2$$$ integers $$$N$$$ $$$(1 \le N \le 22)$$$ and $$$K$$$ $$$(1 \le K \le 22)$$$ $$$(2 \le N+K \le 23)$$$, representing the number of players and the number of packages that Coelho shows to Zapi on each purchase, respectively.
This is followed by $$$2^N$$$ lines, each containing $$$K$$$ integers $$$a_{i,0}, a_{i,1}, \dots, a_{i,K-1}$$$ $$$(0 \le a_{i,j} \lt 2^N)$$$, representing the options that Coelho presents to Zapi on the $$$i$$$-th purchase.
The output must contain a single line with the answer: $$$\bigoplus_{i=0}^{2^N-1} F_i$$$ (mod zap).
2 33 2 01 0 11 1 10 3 0
45
1 30 0 01 1 1
9
| Name |
|---|


