
for i in range(int(input())):
    n = [int(i) for i in input().split( )]
    arr1 = set([int(i) for i in input().split( )])
    arr2 = set([int(i) for i in input().split( )])
    if arr1&arr2:
        print("YES")
        print(1, list(arr1&arr2)[0])
    else:
        print("NO")