def common(A, B):
    for i in A:
        if i in B:
            print("YES")
            print("1"+" "+str(i))
            return
    print("NO")
    return
t = int(input())
for t in range(t):
    lens = input()
    A = input()
    B = input()
    A = [int(i) for i in A.split() if i.isdigit()]
    B = [int(i) for i in B.split() if i.isdigit()]
    common(A,B)