def main():
    for _ in range(int(input())):
        input()
        a=list(map(int,input().split()))
        b=list(map(int,input().split()))
        x=-1
        for i in a:
            for j in b:
                if i==j:
                    x=i
        if x==-1:
            print('NO')
        else:
            print('YES')
            print(1,x)
main()