Namboothiri Brahmins migrated to Kerala during the early Middle Ages. Apart from introducing the caste system, they also changed the socio-economic life of the people by commissioning new religious centres. A second Chera Kingdom (c. 800–1102), also known as Kulasekhara dynasty of Mahodayapuram (present-day Kodungallur), was established by Kulasekhara Varman, which ruled over a territory comprising the whole of modern Kerala and a smaller part of modern Tamil Nadu. During the early part of the Kulasekara period, the southern region from Nagercoil to Thiruvalla was ruled by Ay kings, who lost their power in the 10th century, making the region a part of the Kulasekara empire. Under Kulasekhara rule, Kerala witnessed a developing period of art, literature, trade and the Bhakti movement of Hinduism. A Keralite identity, distinct from the Tamils, became linguistically separate during this period around the seventh century. For local administration, the empire was divided into provinces under the rule of Naduvazhis, with each province comprising a number of "Desams" under the control of chieftains, called as "Desavazhis". A number of foreign accounts have mentioned about the presence of considerable Muslim population in the coastal towns. Arab writers such as Al-Masudi of Baghdad (896–956 AD), Muhammad al-Idrisi (1100-1165 AD), Abulfeda (1273-1331 AD), and Al-Dimashqi (1256-1327 AD) mention the Muslim communities in Kerala. Some historians assume that the Mappilas can be considered as the first native, settled Muslim community in South Asia.