def readints():
    return map(int, input().split())


def main():
    _ = readints()
    a = set(readints())
    for e in readints():
        if e in a:
            print("YES\n1 {}".format(e))
            return

    print("NO")

tests = int(input())
for _ in range(tests):
    main()
