
def intersection(lst1, lst2):
    return list(set(lst1) & set(lst2))
for _ in range(int(input())):
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=intersection(a,b)
    if len(c)==0:
        print("NO")
    else:
        print("YES")
        print(1,c[0])