n = int(input())
result = []
for i in range(n):
    l1, l2 = map(int, input().split())
    list1 = input().split()
    list2 = input().split()
    set1 = set(list1)
    set2 = set(list2)
    set1 = set1.intersection(set2)
    if set1:
        result.append(list(set1))
    else:
        result.append(0)


for i in result:
    if i == 0:
        print('NO')
    else:
        print('YES')
        print(1, end = ' ')
        print(i[0], end= ' ')
        print()
    