x = int(input())
for i in range(x):
    d = list(map(int,input().split()))
    arr1 = list(map(int,input().split()))
    arr2 = list(map(int,input().split()))
    dict1 = {}
    store = []
    for op in range(d[0]):
        dict1[arr1[op]] = 1
    for op in range(d[1]):
        if dict1.get(arr2[op])!=None:

            store.append(arr2[op])
            break
    if len(store)==0:
        print("NO")
    else:
        print("YES")
        print(1,*store)