# inp.readline()
# int(inp.readline())
# out.write()
# raw_input()
# map(int,raw_input().split())
# map(int,inp.readline().split())
# for _ in xrange(input()):
# print "Case #"+str(_+1)+": "+  
if __name__ == "__main__":
    from sys import stdin as inp, stdout as out
    for _ in xrange(input()):
        n,m=map(int,raw_input().split())
        a=set(map(int,raw_input().split()))
        a&=set(map(int,raw_input().split()))
        if a:
            print 'YES'
            print 1,a.pop()
        else:
            print 'NO'