시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 2 2 2 100.000%

문제

The Jaccard similarity coefficient is usually used for measuring the similarity of two sets. Give two sets A and B, the Jaccard similarity coefficient, J(A, B), is defined as the size of the intersection divided by the size of the union of the two sets. That is, J(A, B) = |A∩B|/|A∪B|. For example, if A = {1, 3, 7, 8} and B = {1, 7, 9}, then J(A, B) = |{1,7}|/|{1,3,7,8,9}| = 2/5.

Assume the element i in the set is an integer between 0 to 9 (0 ≤ i ≤ 9) and the size of the set is no larger than 10. Please write a program to compute the Jaccard similarity coefficient of two sets A and B. And output 1 if J(A, B) > 0.5 and 0 if J(A, B) ≤ 0.5.

입력

The first line of the input file contains an integer T (T ≤ 25) indicating the number of test cases to follow.

Each test case will consist of three lines. The first line contains two integers m and n (0 < m, n ≤ 10), indicating the number of elements of sets A and B, respectively. The second line contains m integers (the elements of set A) and the third line contains n integers (the elements of set B).

You may assume:

  • 1 ≤ T ≤ 25
  • m ≤ 10 and n ≤ 10

출력

For each test case, output 1 if J(A, B) > 0.5 and 0 if J(A, B) ≤ 0.5.

예제 입력

3
5 6
0 2 3 5 6
1 2 4 6 7 9
3 2
1 4 6
4 6
7 7
0 1 3 4 6 8 9
0 1 2 3 4 6 7

예제 출력

0
1
1

힌트