for _ in range(int(input())):
    l = input().split()
    a = input().split()
    b = input().split()
    k=0
    for i in a:
        if i in b:
            k=i
            break
    if k!=0:
        print('YES')
        print(1, k)
    else:
        print('NO')