t= int(input())
while t:
    t -= 1
    inp = input()
    n = input()
    n = n.split()
    n = map(int, n)
    m = input()
    m = m.split()
    m = map(int, m)
    inter = list(set(m) & set(n))
    if len(inter) == 0:
        print("NO")
    else:
        print("YES")
        print("1 " + str(inter[0]))