tests = int(input())
for test in range(tests):
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    c = set(a) & set(b)
    if len(c) == 0:
        print('No')
    else:
        print('Yes')
        print(1, list(c)[0])
