def func(A,B):
    for i in A:
        for j in B:
            if i==j:
                res=i
                print('Yes')
                return 1,i
    return -1

t=int(input())
for i in range(t):
    n,m=list(map(int, input().split()))
    # A=input()
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    res=func(A,B)
    if res==-1:
        print('No')
    else:
        print(res[0],res[1])