test=int(input())
def solve():
    arr=[int(i) for i in input().split()]
    
    arr1=[int(i) for i in input().split()]
    arr2=[int(i) for i in input().split()]
    for i in range(len(arr1)):
        for j in range(len(arr2)):
            if arr1[i]==arr2[j]:
                print("YES")
                print("1",arr1[i])
                return
    print("NO")
while test:
    solve()
    test-=1