for _ in range(int(input())):
    a,b=map(int,input().split())
    arr=list(map(int,input().split()))
    br = list(map(int, input().split()))
    sr=set(arr)
    tr=set(br)
    kr=sr.intersection(tr)
    if(len(kr)==0):
        print("NO")
    else:
        print("YES")
        print(1,kr.pop())
