from random import choice

def main():
    n = int(input())
    res = None
    for i in range(n):
        n, m = map(int, input().split())
        a = set([int(x) for x in input().split()])
        b = set([int(x) for x in input().split()])
        temp = a.intersection(b)
        if temp != set():
            res = choice(list(temp))
            print('YES')
            print(1, res)
        else:
            print('NO')
    return 1

main()