1
2 2
1 1
1 2
 1
1 3
3
1 2 3
 1
1 1
1000
1000
 1
2 2
2 2
2 2
 5
4 5
10 8 6 4
1 2 3 4 5
1 1
3
3
1 1
3
2
5 3
1000 2 2 2 3
3 1 5
5 5
1 2 3 4 5
1 2 3 4 5
 1
4 4
1 1 1 1
1 2 3 4
 1
2 3
1 1
1 2 3

YES
1 1
 YES
1 3
 YES
1 1000
 YES
1 2
 YES
1 4
YES
1 3
NO
YES
1 3
YES
1 1
 YES
1 1
 YES
1 1

test_cases = int(raw_input())

for i in range(test_cases):
    size_first, size_second = raw_input().split(" ")

    first_array = raw_input().split(" ")
    second_array = raw_input().split(" ")

    aux = True
    x = first_array

    for element in second_array:
        if element not in first_array:
            continue
        else:
            print "YES"
            print 1, element
            aux = False
            break

    if(aux == True):
        print "NO"
