for _ in range(int(input())):
    n = input()
    a =set(map(int,input().split()))
    b = set(map(int,input().split()))
    x = list(a.intersection(b))
    if len(x)>0:
        print("YES")
        print(1,x[0])
    else:
        print("NO")