for _ in range(int(input())):
    X = list(map(int, input().split()))
    First, Second = set(list(map(int, input().split()))), set(list(map(int, input().split())))
    Common = First.intersection(Second)
    if len(Common)!=0:
        print("YES")
        print("1", list(Common)[0])
    else:
        print("NO")

# New Start