t=int(input())

for _ in range(t):
    u=input()
    a=[int(x) for x in input().split()]
    b=[int(x) for x in input().split()]
    ans=False
    for i in b:
        if i in a:
            print("YES")
            print(f"1 {i}")
            ans=True
            break
    if ans==False:
        print("NO")