On a winter morning during the Hongzhi reign of the Ming dynasty, a young man walked into a walled examination compound in Beijing. The compound was a grid of long, narrow alleys, and along each alley, hundreds of identical brick cubicles lined up like cells in a honeycomb. Each cubicle was just wide enough for a grown man to lie down. Each had a wooden plank that served as both desk and bed, a chamber pot, and nothing else.

The examination offered a possible route across an influential social ideal often called China's four classes or four occupations: scholars, farmers, artisans, and merchants. Passing could move a man toward the scholar-official elite, but the route was neither open nor equal in practice. Years of education cost money and time, some families faced formal restrictions, and wealthier candidates began with advantages that a vegetable seller's son did not have.

The young man found his assigned cell, crawled inside, and arranged his supplies: a brush, an inkstone, a water flask, a few pieces of dried food. Behind him, a guard pushed the door shut.

His name was Lun Wenxu. He had walked from Foshan -- two months on foot, across the mountains of northern Guangdong, through the river towns of Hunan and Hubei, and onto the northern plain. His family had sold vegetables for three generations. Candidates arrived with very different amounts of preparation and patronage, but inside the compound each still faced the same immediate test: three days, a set of essays, and a result that could redirect an entire household.

A mural of three scholar officials in a hall
The mural honors Lun Wenxu's three sons who passed imperial exams AI-generated illustration by On the Great Wall

How China's Four Classes Ranked Society

The four occupations -- scholar, farmer, artisan, and merchant -- became an influential way to describe an orderly society. The scheme is associated with ideas recorded around the time of Guan Zhong and was later given a stronger moral hierarchy by Confucian thinkers. Scholars governed. Farmers produced food. Artisans made useful things. Merchants moved goods and were often ranked last. Real communities were far messier than those four boxes, and occupation did not operate like a single fixed legal caste.

The ranking was not a simple measure of wealth. A prosperous merchant could be richer than a magistrate while still seeking the cultural standing associated with scholarship and office. Money could also buy tutors, books, and years away from work, giving affluent households a better chance of preparing a son for the examinations.

The hierarchy praised agriculture and treated commerce with suspicion, but the categories never fully described how people lived. Families combined farming, craft, trade, and study. Successful merchants invested in land and education; officials came from households with different economic backgrounds. The examination system operated inside this shifting society rather than above it.

So they built a door.

The imperial examination, or *keju*, was one route toward official status. Eligibility widened over the system's long history, but it was not universal: women were excluded, some occupational and legal categories faced restrictions, and years of classical education remained beyond many households. Passing an examination could bring a degree and eligibility for office, not an automatic appointment or equality with established elite families.

A boy reading by light shining through a hole in the wall
The idiom zao bi tou guang tells of a poor scholar who carved through a wall to borrow light AI-generated illustration by On the Great Wall

The Vegetable Seller Who Walked to Beijing

Lun Wenxu was born in 1467 in Liyong village, on the outskirts of Foshan. His father farmed when there was land, worked as a hired hand when there was not, and ferried a boat across the river when there was nothing else. The family could not afford a private tutor. When Lun was two or three, his father taught him characters by tracing them in the sand.

At seven, he began lingering outside the village schoolhouse, listening through the window. The teacher noticed. Impressed and moved, he let the boy attend without charging fees. But when the old teacher died a few years later, Lun was back on the street -- this time behind a carrying pole, a basket of vegetables on each end, hawking greens through the alleys of Foshan. He studied at night by moonlight because his family could not afford lamp oil.

Two encounters changed his trajectory. The first came at Xichan Temple, where Lun delivered vegetables to the monks. Two kitchen monks, knowing his reputation for cleverness, made a demand: they would buy his vegetables at a good price only if he could write a couplet for the temple's Hall of the Sages that embedded the number one hundred. Lun thought for a moment and wrote:

"Seventy-two sages of the Apricot Altar, each one a saint among saints; twenty-eight generals of the Cloud Terrace, each one a lord among lords."

Seventy-two plus twenty-eight equals one hundred. The monks paid double for his vegetables.

The second came when he hid under the altar of the temple's main hall, hoping to catch a glimpse of the governor-general of Guangdong and Guangxi, who was visiting to offer incense. He was discovered. The temple abbot, instead of punishing him, told the governor that the boy was a prodigy. The governor tested him with a couplet. Lun answered without hesitation. Impressed, the governor gave him fifty taels of silver -- enough to leave the vegetable trade and study full-time.

There was also the porridge shop. During his years selling vegetables, Lun often stopped at a small eatery where the owner, pitying the thin, bright-eyed boy who clearly never had enough to eat, would cook him a free bowl of congee every day -- pork meatballs, pork intestine, pork liver, ginger, scallions. Year after year, never charging a copper coin. When Lun returned to Foshan as *zhuangyuan* -- the top-ranked scholar in the entire empire -- he went straight to the shop. The congee had no name. He gave it one: *zhuangyuan jidi zhou*, "Number One Scholar Porridge." Those four characters are still printed on teahouse menus across the Pearl River Delta.

In 1489, Lun passed the provincial examination. In 1499, he took the metropolitan examination in Beijing -- first place -- followed by the palace examination before the emperor himself -- first place again. He was thirty-two years old. From the vegetable market to the throne room, it had taken him twenty-five years.

Students take the national entrance exam
The gaokao is the decisive gateway for millions each June AI-generated illustration by On the Great Wall

Sons of Widows, Students of Moonlight

Lun Wenxu was not an exception. He was the proof of a design.

Fan Zhongyan lost his father at the age of two. His mother remarried, and he grew up in a temple on Changbai Mountain, studying with an intensity that bordered on madness. Every morning, he cooked a single pot of thick porridge, let it cool until it set into a solid block, then cut it into four pieces with a knife -- two for breakfast, two for dinner, with a few pickled vegetables on the side. He became deputy prime minister of the Song dynasty. On his deathbed, he gave away his entire fortune to establish China's first family charitable trust, ensuring that no child in his clan would ever have to study on an empty stomach.

Ouyang Xiu lost his father at four. His mother, too poor to buy paper, taught him to write with a reed stalk in the sand. He became the literary titan of the Northern Song -- imperial academician, deputy prime minister, the man who set the prose standards for an entire dynasty.

Han Yu lost both parents by the age of three and was raised by his elder brother and sister-in-law. He failed the imperial exam three times before passing on his fourth attempt. He went on to become the foremost prose stylist of the Tang dynasty and vice minister of personnel.

Lu Mengzheng was thrown out of his home as a child, along with his mother, by his own father. The two of them lived in a cave carved into a hillside. He became *zhuangyuan*, then prime minister -- three times. Late in life, he wrote an essay called "On Living in a Broken Kiln," whose opening line reads: *The sky holds storms no one can predict, and a man's fortune can change between morning and evening.*

Across successive dynasties, the examinations did bring some newcomers into the educated elite. They also rewarded families able to sustain years of study, sometimes across several generations. Lun's rise matters because mobility was possible, not because it was ordinary or evenly available.

A bowl of zhuangyuan jidi zhou (Top Scholar Congee) served in a traditional Cantonese teahouse
"Zhuangyuan Jidi Zhou" -- Top Scholar Congee -- still appears on teahouse menus across the Pearl River Delta. AI-generated illustration by On the Great Wall

The Heads That Rolled to Keep the Door Honest

A door is only as honest as the people guarding it. And for 1,300 years, the Chinese state guarded the examination door with something more persuasive than regulations. It guarded it with blood.

The system developed elaborate defenses against favoritism and fraud. At major examinations, identifying information could be concealed and papers recopied before grading so handwriting would not reveal a candidate. Searches and identity checks tried to stop hidden notes and impersonation. These safeguards reduced some forms of influence, but scandals and bribery still occurred.

In 1657, during the Shunzhi reign of the early Qing, the Jiangnan provincial examination erupted in scandal. When the results were posted, a parade of known incompetents had passed, while several of the region's most respected scholars had failed. Enraged candidates carried a statue of the God of Wealth through the streets of Nanjing in protest -- a gesture of bitter sarcasm, implying that money, not merit, had decided the results.

The emperor ordered every successful candidate to retake the exam in Beijing under his personal supervision. Fourteen were stripped of their degrees on the spot. Investigators then uncovered a web of bribery stretching through the examiner ranks. The punishment: Fang You, the chief examiner, and Qian Kaizong, his deputy -- beheaded, their wives and property confiscated. Of the eighteen other examiners, seventeen were hanged; one had died during interrogation. Eight candidates who had paid bribes were each caned forty times and had their property seized.

The harshest penalty was reserved for their families. Each candidate's parents, brothers, wife, and children -- five to eight people per household, nearly seventy people across the eight families, from infants to the elderly -- were marched into exile at Ningguta, a frozen settlement on what is now the Siberian border. The journey took months on foot. Contemporary accounts suggest that fewer than half survived it. For the next fifty years, no one risked cheating on the imperial exams.

Two centuries later, in 1858, the Xianfeng emperor faced his own scandal. The Shuntian provincial exam results included a Beijing opera star among the top ten -- actors were legally barred from sitting the exam at all. Worse, investigators found over fifty papers with serious errors, including one with more than three hundred incorrect characters that had somehow passed. The chief examiner this time was Bojun, a grand secretary and grand councillor -- one of the most powerful men in the empire, a minister who stood beside the emperor every day. Xianfeng ordered him beheaded at Caishikou, the public execution ground in Beijing. According to witnesses, Bojun had packed his bags for exile, fully expecting his rank to save his life. Three co-conspirators were executed alongside him.

The severity of these cases showed how much legitimacy the state attached to the examinations. It did not make the system fully fair. A candidate's paper might be anonymized, but everything that allowed him to reach the examination hall -- literacy, tutors, books, travel, and years without full-time labor -- remained unequally distributed.

The Door with a New Name

Lun Wenxu died at forty-seven, still serving as an imperial academician. He never reached the highest offices of state. But his sons took the exam. His grandsons took it too.

The porridge shop in Liyong village is long gone. But *zhuangyuan jidi zhou* remains -- a bowl of pork scraps and rice that a vegetable seller named after he became the first scholar in the empire.

The imperial examination was abolished in 1905. Modern China later built very different systems of schools and standardized testing, including the *gaokao*. The comparison should not erase the distance between them, but the old tension remains recognizable: an exam can widen opportunity while still reflecting unequal preparation outside the examination hall.

The door has a different name now. But it is still there.