Emperor Shengzong of Liao (16 January 972 – 25 June 1031), personal name Wenshunu, sinicised name Yelü Longxu, was the sixth emperor of the Khitan-led Chinese Liao dynasty and its longest reigning monarch. Conflict with the Northern Song dynasty Emperor Shengzong succeeded his father, Emperor Jingzong, at the age of 12 in 982. As he was too young to rule at the time, his mother, Empress Dowager Xiao, became the regent. Emperor Taizong of the Northern Song dynasty sought to take advantage of the situation by launching an invasion on the Liao dynasty's southern capital (present-day Beijing) in the contentious Sixteen Prefectures in 986. Three large Song armies were sent to three different strategic locations on the approach to the southern capital. While initially successful, the young Emperor Shengzong, along with Empress Dowager Xiao, led an army of Liao cavalry to counter the enemy and defeated the Song forces at the Battle of the Qigou Pass in June. Empress Dowager Xiao appointed Yelü Xiuge as her senior general to continue attacks on the Song dynasty in retaliation until the following year. In 1004, the Liao dynasty carried out a large-scale invasion of Song territory, camping out in the town of Shanyuan, about 100 miles north of the Song capital of Kaifeng. This resulted in the Treaty of Shanyuan, signed in mid-January 1005. According to this treaty, the Song dynasty would pay an annual tribute of 200,000 bolts of silk and 100,000 taels of silver to the Liao dynasty in exchange for peace. This arrangement would remain in place with modifications until the end of the Liao dynasty, and in fact, the Jurchens could continue this arrangement with the Song dynasty with the founding of their Jin dynasty. Examination system Emperor Shengzong also institutionalised state examinations for the selection of officials, which was done in 988, based on models used by the Han Chinese-led Tang and Song dynasties. Despite the importance of the return of the examination system, it initially only opened the road for very small numbers, as only three to five were awarded initially, and the number only increased to between 30 and 130 candidates passing the triennial exams by 1014. Most jinshi degree holders were not even appointed to office, as Khitan aristocrats were far more likely to receive appointments. Khitan people receiving appointments did so specifically through patronage, as they were expressly prohibited from taking the examinations.