Allocation of resources to male and female functions in hermaphrodites