sentences:  The Newar caste structure resembles more closely that of North India and Madheshis than that of Khas 'Parbatiyas' in that all four Varna (Brahmin, Kshatriya, Vaishya and Shudra) and untouchables are represented.The social structure of Newars is unique as it is the last remaining example of a pre-Islamic North Indic civilisation in which Buddhist elements enjoy equal status with the Brahmanic elements.According to various historical sources, even though the presence of "varna" and caste had been a known element in the social structure of the Kathmandu Valley since the Licchavi period (c., 3rd century CE), majority of the residents of the Nepal Valley were for the first time codified into a written code only in the 14th century in the "Nepalarastrasastra" by the Maithil–origin king Jayasthithi Malla (1354–1395 A.D.) Jayasthithi Malla, with the aid of five Kānyakubja and Maithil Brahmins whom he invited from the Indian plains, divided the population of the valley into each of four major classes ("varna")—Brahmin, Kshatriya, Vaishya, Shudra—derived from the ancient Hindu text Manusmriti and based on individual's occupational roles.