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


