def solve():
    [m, n] = [int(x) for x in input().split()]
    A = set([int(x) for x in input().split()])
    B = set([int(x) for x in input().split()])

    for i in A:
        if i in B:
            print('Yes')
            print(1, i)
            return
    
    print('NO')



def main():
    n = int(input())
    while n > 0:
        solve()
        # print(ans)
        n -= 1


main()