
def c(s1,s2):
    a = s1+s2
    for i in a:
        if a.count(i)>1:
            print("YES")
            print(1,i)
            return
    print("NO")
    return 
          
t = int(input())
for i in range(t):
    n = input()
    s1 =  list(map(int,input().split()))
    s2 = list(map(int,input().split()))
    s1 = list(set(s1))
    s2 = list(set(s2))
    c(s1,s2)
       
    
              