#Codeforces1382A
for i in range(int(input())):
    z = input().split()

    n = input().split()
    m = input().split()

    bol = False

    for i in n:
        if i in m:
            print("YES\n1", i)
            bol = True
            break

    if not bol:
        print("NO")
