t = int(input())

for caseNr in range(1, t + 1):
    nm = list(map(int, input().split()))
    a_s = list(map(int, input().split()))
    b_s = list(map(int, input().split()))
    
    lst = [value for value in a_s if value in b_s] 
    
    if not lst:
        print("NO")
    else:
        print("YES")
        print("1 "+str(lst[0]))
    