What legendary king eventually takes over the state