for _ in range(int(input())):
    input()
    a=set(map(int,input().split()))
    b=set(map(int,input().split()))
    ans='NO'
    for x in a:
        if x in b:
            ans='YES'
            break
    print(ans)
    if ans=='YES':
        print(1,x)