t = int(input())
for _ in range(t):
    l = list(map(int,input().split()))
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    a.sort()
    b.sort()
    ans =0
    for i in a:
        for j in b:
            if i == j:
                ans=i
            if ans>0:
                break
        if ans>0:
            break


    if ans:
        print('Yes')
        print(1,ans)
    else:
        print('No')