T = int(input())
for test in range(T):
    input()
    a = set([int(u) for u in input().split()])
    b = set([int(u) for u in input().split()])
    u = a.intersection(b)
    if len(u)  == 0:
        print("NO")
    else:
        print("YES")
        for i in u:
            print(1, i)
            break
