The emergence and spread of religions