t = int(input())
for i in range(t):
    n, m = input().split()
    a = set(input().split())
    b = set(input().split())
    c = b.intersection(a)
    if len(c):
        print('YES')
        print(1, c.pop())
    else:
        print('NO')