t=int(input())
while(t):
    la=input()
    c=1
    a=[int(x) for x in input().split(" ")]
    b=[int(x) for x in input().split(" ")]
    for i in a:
        for j in b:
            if(i==j):
                print("YES")
                print('1 ',i)
                c=0
                break
        if(c==0):
            break
    if(c==1):
        print("NO")
    t=t-1