t = int(input())

for i in range(t):
    # test cases
    input()  # Burn sizes
    elements_1 = [int(x) for x in input().split()]
    elements_2 = [int(x) for x in input().split()]

    found = False
    for el in elements_1:
        if el in elements_2:
            found = True
            print('YES')
            print(1, el)
            break
    if not found:
        print('No')
