Imperial examination system was followed in both tang and song dynasty, people were allowed to enter political positions based on merit but it became corrupt too.
Explanation:
The civil service rose in dignity when the military dominance became weak in China. Selection examinations were held every three years at the district, provincial, and metropolitan levels. Only two hundred over thousand applicants were given the Jinshi degree. This was the highest degree and appointed on government posts. From this time on, civil servants became China’s most envied elite, replacing the nobles and landlords. Officials that held important government positions were corrupt.
During Tang dynasty they selected the officials for political positions in three ways. First, those descendants of high-ranked officials or royal families could inherit their ancestors' official titles. Second, those who served the emperors and their sons had opportunities to be recommended to be officials. Third, those who passed the imperial examinations could become officials.