In the middle of the Ming Dynasty, Grand Tutor Pang Fei became powerful because his sister was the emperor's beloved concubine. When the empress became pregnant, Grand Tutor Pang feared that his sister would lose favor. He devised a scheme to replace the royal child with a dead cat, causing the empress to be banished to the cold palace. The prince was thus abandoned and left at the doorstep of a wandering magician named Liu Jing. Coincidentally, a courtesan also placed her infant outside Liu Jing's door at the same time. Meanwhile, Grand Tutor Pang's wife, who had been unable to bear children, had secretly adopted a baby from a peasant family. As fate would have it, when passing by Liu Jing's house, she inadvertently switched the babies. These three infants, born on the same day, came from vastly different backgrounds but were all abandoned and subsequently adopted.
Who was the real prince? Fate would decide. It wasn't until twenty years later, during an imperial examination, that these three individuals met again and became close friends. The baby taken to the Grand Tutor's mansion grew up to be named Pang Yuandan, who was greatly favored by the Grand Tutor despite his mediocre talents. The two children raised by Liu Jing were named Liu Jincai and Liu Sheng. Jincai was carefree and eccentric, while Liu Sheng was exceptionally intelligent, well-read in poetry and books, and skilled in medicine.
The Grand Tutor bribed the examiners to change the top scholar title from Liu Sheng to Yuandan. Filled with grievances, Liu Sheng encountered a young woman named Duan Yu, who mistakenly thought he was attempting suicide and came to his rescue. Duan Yu's father, Duan Bai Xiong, was entrusted by the emperor to escort a priceless night pearl from the Western Regions but was ambushed and imprisoned. To clear her father's name, Duan Yu disguised herself as a man and infiltrated the government office to investigate. At this time, Liu Sheng also joined the office under Pang Yuandan's jurisdiction and solved many strange cases. However, he remained unaware that his loyal comrade-in-arms was actually the dream lover he longed for.
It turned out that the mastermind behind the night pearl case was none other than Grand Tutor Pang. Fearing that the conspiracy of switching babies twenty years ago would be exposed, he dispatched his trusted assistant Feng Guohua to investigate the prince's whereabouts, determined to eliminate any potential threats to protect his position.