def task():
    s = input()
    a = set(map(int, input().split()))
    b = set(map(int, input().split()))
    res = a & b
    if len(res) == 0:
        print('NO')
    else:
        print('YES')
        print(1, min(res))

n = int(input())
for _ in range(n):
    task()
