N = int(input())
for i in range(N):
    input()
    a = list(map(int, input().split(' ')))
    b = list(map(int, input().split(' ')))
    res = list(filter(lambda x: x in a, b))
    if len(res) > 0:
        print('YES\n1', res[0])
    else:
        print('NO')
