def solve(a_list, b_list):
    a, b = {}, {}
    for n in a_list:
        a[n] = True
    for n in b_list:
        b[n] = True
    for i in range(1, 1001):
        if a.get(i) and b.get(i):
            print('YES')
            print(1, i)
            return
    print('NO')


if __name__ == '__main__':
    t = int(input())
    for t in range(t):
        input()
        a = [int(i) for i in input().split()]
        b = [int(i) for i in input().split()]
        solve(a, b)
