Its officials wrote, compiled, and maintained the government and historical records. Seonggyungwan or Royal Academy (성균관, 成均館) - Royal university served to prepare the future government officials. Those who passed first two stages of gwageo examinations were admitted to Seonggyungwan. The class size was usually 200 students, who lived in the residential hall and followed strict routine and school rules. It also served as the state shrine for Chinese and Korean Confucian scholars. The official in charge was Daesaseong (대사성, 大司成), of senior third rank, and 36 other officials including those from other offices were involved in running the academy. Local government The ranked officials were sent from the central government. Sometimes a secret royal inspector (Amhaeng-eosa, 암행어사) was sent to travel incognito and monitor the provincial officials. Secret inspectors were generally young officials of lower rank but invested with royal authority to dismiss corrupt officials. Provinces: (Do, 도) – There were eight provinces, each of them governed by a Governor (Gwanchalsa, 관찰사), a position of junior second rank. Special cities: Bu (부) – administrative offices in charge of five major cities in provinces. Each Bu was led by a Buyoon (부윤), which was equivalent to Governor in rank. Departments: Mok (목) – There were twenty moks, which governed large counties named 'ju'(주). They were governed by Moksa (목사), of senior third rank. Counties: (Gun, 군) – There were eighty counties in Joseon, each governed by Gunsu (군수), a junior fourth rank. Settlements or communities: Hyeon (현) – Large hyeons were governed by Hyeongryeong (현령) of junior fifth rank while smaller hyeons were governed by Hyeonggam (현감) of junior sixth rank. Each county and hyeon was overseen by a local magistrate appointed by the central government. The yangban of each county (gun) composed a Local Office. This interacted with local officials, typically of a lower class, who were known as hyangni. The hyangni typically served for life in hereditary posts. The hyangni of each county had an ambassador in the capital who was charged with communicating among them and the central government. Factions Throughout the dynasty, various regional and ideological factions struggled for dominance in the political system. In the earliest years of Joseon, tension between the capital faction and the Yeongnam-based Sarim faction dominated national politics. The different Seowon across the country, which combined the functions of Confucian shrines with educational institutions, often reflected the factional alignment of the