powerful people, the opportunity to work for the state, but in practice only sons of the gentry could gain the necessary education to take the exam; royal relatives of the five highest ranks were, instead, left out on purpose. In 960, the king introduced different colours for court robes to distinguish officials of different ranks. During Gwangjong's reign, medical centers known as Daebi-won (), which provided free medicines to poor patients, were set up in Kaesong and Pyongyang, later expanding in the provinces as the Hyeminguk (). Taejo had established regional granaries () to face the times of drought, and Gwangjong added jewibo (), stores which charged interests on grain loans, which were then used for poor relief. These measures, even if in modified forms, kept on working for the next 900 years, parallel to better cultivation methods to keep up with the growth of population. When emperor Shizong of Later Zhou died in 959, leaving the throne to his six-year-old son, the dynasty fell as the army, who was marching towards the northern border, defected and chose its commander Zhao Kuangyin as emperor. As Zhao decided to return from battlefield to found the Song dynasty, he left the mountains of Manchuria and the northern plains to Khitans and Jurchens. To improve Goryeo's defences, Gwangjong reorganized and expanded military, and built twelve garrisons along the northeast and northwest borders; also, under his reign, the kingdom moved the border beyond the Chongchon river, heading towards the Yalu river. Gwangjong saw the association of religious institutions and the state as an aid to subdue local lords, and chose the abbot of Haeinsa Temple to promote Buddhism among the people. He took capable monks as advisers, and promoted the construction of temples: for example, he built the Yongjusa Temple in Cheongju, North Chungcheong, in 962, and the Cheongpyeongsa Temple in Chuncheon, Gangwon, in 973. The king also created an exam for Buddhist priests, called seonggwa (), to link the government and the church, and he attempted to make peace between the Zen and textual schools to unify them under a single order, but he didn't have much success. Other actions undertaken to reinforce the royal authority were naming Goryeo an empire and himself Emperor, thus ending tributary relationships with China; calling Kaesong the Imperial Capital and Pyongyang the Western Capital, and adopting the era name Gwangdeok () from 949 to 951, and Junpung