"Three visits to trouble the world, two dynasties to improve the hearts of veterans" refers to Zhuge Liang.
These two lines of poetry come from "The Prime Minister of Shu" written by Du Fu in the Tang Dynasty. The original text is as follows:
Where can I find the ancestral hall of the Prime Minister? There is a lot of people outside Jinguan City.
The green grass reflects the spring color on the steps, and the oriole sounds good in the sky through the leaves.
Three visits to trouble the world, two dynasties to open the hearts of old ministers.
He died before leaving the army, which made the hero burst into tears.
Translation: Where to find the ancestral hall of Zhuge Liang, the Marquis of Wu? In the place with dense cypress trees outside Chengdu. The green grass reflecting on the stone steps is nothing more than the beauty of spring; the oriole through the leaves is nothing more than its empty sound. In order to unify the world, Liu Bei visited the thatched cottage three times, asked Zhuge Liang for advice, and assisted the loyal ministers of two generations of monarchs. It is a pity that he died before the final victory was achieved when he set out to attack Wei, which often made future generations of heroes wet their clothes with emotion!
Creative background
The poem "The Prime Minister of Shu", according to Qiu Zhaoao's annotation, was dated to the spring of 760 AD (the first year of Emperor Suzong's reign in the Tang Dynasty), when Du Fu "composed it when he first arrived in Chengdu". In December of 759 AD (the second year of Emperor Suzong's reign in the Tang Dynasty), Du Fu ended his four-year wandering life in Qinzhou and Tonggu (now Chengxian County, Gansu Province) and arrived in Chengdu. With the help of friends, he Settled by the Huanhua River.
Chengdu is where the Shu Han Dynasty established its capital. There is a Zhuge Liang Temple in the northwest of the city, called Wuhou Temple. In the spring of the first year of Shangyuan (AD 760) by Emperor Suzong of the Tang Dynasty, he visited Zhuge Wuhou Temple and wrote this touching and eternal song.