According to the ancient texts The Biography of Zhong Kui, Tang Anecdotes, and Supplement to Brush Talks, the year Emperor Xuanzong ascended the throne, Zhong Kui (played by Ouyang Zhenhua) traveled to Chang'an to sit the imperial examinations. He composed five poems titled Banquet Awaiting at Yingzhou, earning the chief examiner's praise as a "rare genius" and placing first among the successful candidates. But during the palace examination, the treacherous chancellor Lu Qi judged him by his appearance and repeatedly slandered him, costing him the top scholar title. In a fit of rage, Zhong Kui struck his head against a palace pillar and died, shocking the entire court. Xuanzong issued an edict naming him the Great Deity Who Subdues Demons, ordering him to travel the land and "slay monsters and drive out evil," and buried him with the honors of a top scholar. The Jade Emperor was moved by Zhong Kui's willingness to sacrifice himself in the cause of justice, so he deified him and tasked him with handling injustices in the mortal world.