The morphologies and physical properties of ultracompact H II regions