tests = int(input())

i = 0
while i < tests:
    lengths = input().split()
    a = set(input().split())
    b = input().split()

    found = False
    for number in b:
        if number in a:
            found = True
            print("YES")
            print(1, number)
            break
    if not found:
        print("NO")
    i += 1