def func(n,m):
    n = list(map(int,n.split()))
    m = list(map(int,m.split()))
    common = list(set(n).intersection(set(m)))
    if len(common) == 0:
        return "NO"
    else:
        return "YES" + '\n' + '1 ' + str(common[0])

def main():
    t = int(input())
    for i in range(t):
        input()
        n = input()
        m = input()
        print(func(n,m))

main()