| IPL 2026 |
|---|
| Закончено |
You are given two tournaments $$$A$$$ and $$$B$$$ on the same set of vertices $$$1,2,\ldots,n$$$. Recall that a tournament is an orientation of the complete graph: for every pair of distinct vertices $$$i$$$ and $$$j$$$, exactly one of the edges $$$i\to j$$$ or $$$j\to i$$$ exist.
You may perform the following operation on the tournament $$$A$$$ any number of times:
Find any sequence of operations that transforms $$$A$$$ into $$$B$$$, or determine that it is impossible.
It can be shown that whenever it is possible, there exists a valid sequence using at most $$$\frac{n(n-1)}{2}$$$ operations.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 500$$$). The description of the test cases follows.
The first line contains a single integer $$$t$$$ — the number of test cases.
Each test case begins with a single integer $$$n$$$ ($$$2 \le n \le 500$$$) — the number of vertices.
The next $$$n$$$ lines describe tournament $$$A$$$. The $$$i$$$-th of these lines contains a binary string $$$A_i$$$ of length $$$n$$$. Here, $$$A_{ij}=1$$$ means that vertex $$$i$$$ beats vertex $$$j$$$ in tournament $$$A$$$, and $$$A_{ij}=0$$$ means otherwise.
The next $$$n$$$ lines describe tournament $$$B$$$ in the same format.
It is guaranteed that both $$$A$$$ and $$$B$$$ are valid tournaments, i.e.:
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$500$$$.
For each test case:
If there are multiple valid answers, output any of them.
23010001100001100010401110011000100000011101100010000
12 3 1-1
| Название |
|---|


