numberoftests = int(input())
for _ in range(numberoftests):
    whocares = input()
    a = input().split()
    b = input().split()
    combined = [x for x in a if x in b]
    if len(combined) == 0:
        print('NO')
    else:
        print('YES')
        print('1',combined[0])