The Qin and Han dynasties unified China and established a Confucian state ideology. The Qin emperor Qin Shi Huang used harsh legalist policies like unpaid corvee labor and severe punishments to unify the territories. He also had the famous terracotta army built. The Han dynasty adopted Confucianism as the state ideology, establishing civil service exams based on Confucian classics. The Records of the Grand Historian by Sima Qian documented Chinese history from the Yellow Emperor to his own time in over 500,000 characters.