for i in range(int(input())):
    a,b=map(int,input().split())
    l1=list(map(int,input().split()))
    l2=list(map(int,input().split()))
    d=0
    for i in l1:
        for j in l2:
            if(i==j):
                print('YES')
                print(1,i)
                d=1
                break
        if(d==1):
            break
    if(d==0):
        print('NO')