for _ in range(int(input())):
    n,m=map(int,input().split())
    x=[int(x) for x in input().split()]
    y=[int(x) for x in input().split()]
    x=set(x)
    y=set(y)
    z=x.intersection(y)
    if len(z)>0:
        print('YES')
        z=list(z)
        print(1,z[0])
    else:print('NO')