t = int(input())
for i in range(t):
    count = 0
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    arr = []
    for i in a:
        if i in b:
            count += 1
            arr.append(i)
            break

    if count>0:
        print("YES")
        print(count,end = " ")
        print(*arr)
    else:
        print("NO")