def solve(a_array, b_array):
    for a_element in a_array:
        for b_element in b_array:
            if a_element == b_element:
                print("YES\n" + "1 " + a_element)
                return
    print("NO")


test_cases = int(input())
for case in range(test_cases):
    input()
    a_array = input().split(" ")
    b_array = input().split(" ")
    solve(a_array, b_array)
