def common():
    for i in range(int(input())): 
        x=input()
        a=set(list(map(int,input().split())))
        b=set(map(int,input().split()))
        vault=a.intersection(b)
        if len(vault)<1:
            print('NO')
        else: 
            print('YES')
            print(f'1 {vault.pop()}')



common()