num = int(input())
for i in range(num):
    [m, n] = input().split()
    m = int(m)
    n = int(n)
    ms = input().split()
    ms = set([int(i) for i in ms])
    ns = input().split()
    ns = set([int(i) for i in ns])
    q = ms & ns
    if not q:
        print("NO")
    else:
        print("YES")
        print(1, list(q)[0])
