n = int(input())

for i in range(n):
    m = input()
    a = input()
    a = a.split()
    a = list(map(int, a))
    b = input()
    b = b.split()
    b = list(map(int, b))
    flag = False
    for e in a:
        if flag is True:
            break
        if e in b:
            print("YES")
            print(1, e)
            flag = True
    if flag is False:
        print("NO")
