for _ in range(int(input())):
    i,j = map(int,input().split())
    fst = list(map(int,input().split()))
    snd = list(map(int,input().split()))
    list1_as_set = set(fst)
    intersection = list1_as_set.intersection(snd)
    intersection_as_list = list(intersection)
    if len (intersection_as_list) != 0:
        print("YES")
        print(1, intersection_as_list[0])
    else: print("NO")
