for tests in range(int(input())):
    found = 0
    z = input()
    first = [i for i in map(int,input().split())]
    second = [i for i in map(int,input().split())]
    for i in second:
        if i in first:
            found = i
            break
    if(found):
        print("YES \n1 {}".format(found))
    else:
        print("NO")
