Cognitive flexibility, or the ability to make different decisions to meet ever-changing demands from the environment, is essential for the survival of humans and other animals. To support this key ability, the brain needs to reorganize its activity patterns depending on the current behavioral context, but we still understand little about how this functional reorganization is accomplished. This project will investigate this fundamental question by asking how multiple mouse brain regions act in concert to support task switching, a common type of flexible cognitive behavior. Beyond leading to better understanding of basic brain mechanisms, this research could inform future work that aims to treat cognitive inflexibility, which is pervasive in brain disorders like autism, schizophrenia, and dementia. The project will also have other broader societal impacts. First, it will provide numerous opportunities for undergraduate and graduate education in neuroscience. Second, it will include outreach to schoolteachers and children to raise awareness about the detriments of excessive task switching, which has vastly increased with pervasive digital technologies like smartphones and particularly affects learning in school-aged children. The central goal of this proposal is to contrast two competing models of how the brain reorganizes its activity patterns task dependently: in the intracortical model, task-specific activity is fully generated within the cerebral cortex. In the external