The origins of diversity in the adaptive immune system and the brain