t = int(input())

for _ in range(t):
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = []
    for i in a:
        if i in b:
            c.append(i)
            break
    if len(c)>0:
        print("YES")
        print(len(c), end = ' ')
        for i in c:
            print(i, end = ' ')
        print()
    else:
        print("NO")
