from sys import stdin,stdout
for _ in range(int(stdin.readline())):
    n,n1=map(int,stdin.readline().split())
    a=set(map(int,stdin.readline().split()))
    b=set(map(int,stdin.readline().split()))
    ans=sorted(a&b)
    if not ans:print('NO')
    else:
        print('YES')
        print(1,ans[0])
