创建于 2026/07/16 · 更新于 2026/07/16
You're playing a game.
The game consists of boss battles, indexed . The battles can be completed in any order, but any battle can only be completed once. There are possible rewards for completing a battle, indexed . However, not all rewards can be obtained by completing any battle. For each battle , there is a list of possible rewards . You can only get rewards in after you have completed battle .Additionally, once you have obtained a given reward, you cannot obtain it again.
When you complete battle , you will receive one of rewards from that you have not yet received, at random. If you have already obtained all possible rewards from battle , you get nothing.
You want to find out which rewards you can guarantee obtaining. Your task is to, for each independently, find out if there is a strategy that guarantees you will receive reward .
The first line contains one integer —the number of test cases. Each test case is described as follows.
The first line contains two integers and — the number of battles and rewards,respectively.
The next lines describe the possible rewards for completing battles.
The -th line starts with an integer ,followed by integers —the possible rewards for completing battle .
It is guaranteed that the sum of over all test cases doesn't exceed .
For each test case, print a binary string of length . The -th character should be 1 if it is possible to guarantee obtaining reward , and 0 otherwise.
2
4 4
2 1 2
2 2 3
2 2 3
1 3
5 5
1 4
2 1 3
2 4 5
2 2 4
1 5
1110
01011