Jaccard Similarity Threshold

Given two small sets of digits, decide whether their Jaccard similarity is greater than 0.5.

Easy2ImplementationMathInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

The Jaccard similarity coefficient measures how similar two sets are. For two sets AA and BB, the coefficient J(A,B)J(A, B) is the size of the intersection divided by the size of the union, that is J(A,B)=ABABJ(A, B) = \frac{|A \cap B|}{|A \cup B|}. For example, if A={1,3,7,8}A = \{1, 3, 7, 8\} and B={1,7,9}B = \{1, 7, 9\}, then J(A,B)={1,7}{1,3,7,8,9}=25J(A, B) = \frac{|\{1, 7\}|}{|\{1, 3, 7, 8, 9\}|} = \frac{2}{5}.

Every element of a set is an integer between 0 and 9, and no set holds more than 10 elements. Given two sets AA and BB, compute J(A,B)J(A, B) and print 1 when J(A,B)>0.5J(A, B) > 0.5, or 0 when J(A,B)0.5J(A, B) \le 0.5.

Input

The first line contains the number of test cases TT (1T251 \le T \le 25).

Each test case consists of three lines. The first line contains mm and nn, the number of elements of AA and the number of elements of BB (1m,n101 \le m, n \le 10). The second line contains the mm elements of AA and the third line contains the nn elements of BB, separated by spaces. Every element is an integer between 0 and 9, and the same value never appears twice inside one set.

Output

For each test case, print 1 if J(A,B)>0.5J(A, B) > 0.5 and 0 if J(A,B)0.5J(A, B) \le 0.5, one answer per line.