def main():
    for _ in range(int(input())):
        n,m=map(int,input().split())
        a=[int(x) for x in input().split()]
        b=[int(x) for x in input().split()]
        for i in a:
            if(i in b):
                print("Yes")
                print(1,i);
                break
        else:
            print("No")
main()