In 221 BC, Qin Shi Huang conquered the various warring states and created for himself the title of "Huangdi" or "emperor" of the Qin, marking the beginning of imperial China. However, the oppressive government fell soon after his death, and was supplanted by the longer-lived Han dynasty (206 BC – 220 AD). Successive dynasties developed bureaucratic systems that enabled the emperor to control vast territories directly. In the 21 centuries from 206 BC until AD 1912, routine administrative tasks were handled by a special elite of "scholar-officials". Young men, well-versed in calligraphy, history, literature, and philosophy, were carefully selected through difficult government examinations. China's last dynasty was the Qing (1644–1912), which was replaced by the Republic of China in 1912, and then in the mainland by the People's Republic of China in 1949. The Republic of China retreated to the island of Taiwan in 1949. Both the PRC and the ROC currently claim to be the sole legitimate government of China, resulting in an ongoing dispute even after the United Nations recognized the PRC as the government to represent China at all UN conferences in 1971. Hong Kong and Macau transferred sovereignty to China in 1997 and 1999 from the United Kingdom and Portugal respectively, becoming special administrative regions (SARs) of the PRC.