for _ in range(int(input())): n, m = map(int, input().split()) a = list(map(int, input().split())) if n == 0: assert not a b = list(map(int, input().split())) if m == 0: assert not b print('No')