n = int(input())
for i in range(n):
    al, bl = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s1 = []
    for j in a:
        if j in b:
            s1.append(j)
    k = len(s1)
    if k == 0:
        print('NO')
    else:
        print('YES')
        print('1', end=' ')
        print(s1[0])
