for _ in range(int(input())):
    a,b = list(map(int,input().split()))
    arr = set(map(int,input().split()))
    brr = set(map(int,input().split()))

    d = arr & brr
    if len(d) == 0:
        print('NO')
    else:
        d = list(d)
        print('YES')
        print(" ".join(['1',str(d[0])]))