Luoyang). Li defeated him, however, forcing him to abandon Luoyang and flee north of the Yellow River back to the circuit capital Heyang. Li gave chase, and was about to chase the Yellow River, when Liu sent Zhang to try to stop Li. However, as Zhang also resented Liu's hold on the circuit governance, he instead joined Li, and they jointly attacked Heyang but could not capture it. They then withdrew to Huai Prefecture (懷州, in modern Luoyang). As this Heyang Circuit internecine confrontation was going on, the former Tang general Qin Zongquan, who had declared himself emperor at Fengguo Circuit (奉國, headquartered in modern Zhumadian, Henan), sent his general Sun Ru toward Heyang, and Sun soon captured the city. Zhuge Zhongfang fled to Xuanwu Circuit (宣武, headquartered in modern Kaifeng, Henan). Sun thereafter claimed the title of military governor of Heyang. However, Zhang and Li occupied Huai and Ze Prefectures, respectively, and resisted Sun. After Qin thereafter suffered a major defeat at the hands of Xuanwu's military governor Zhu Quanzhong, Sun withdrew from Heyang. Zhang and Li rejoined forces, with Li taking over Heyang and Zhang taking over Luoyang; they then jointly sought aid from the major warlord Li Keyong the military governor of Hedong Circuit (河東, headquartered in modern Taiyuan, Shanxi). Li Keyong sent his officer An Jinjun () to take over Ze Prefecture as prefect and to aid Li Hanzhi and Zhang; he also commissioned Li Hanzhi as the military governor of Heyang and Zhang as the mayor of Henan Municipality (河南, i.e., Luoyang). As vassal of Li Hanzhi/Li Keyong At the time that Zhang Quanyi took over as the mayor of Henan, it was said by historical accounts that the city had been laid waste by the wars, with the remnants of the population gathered within three castles of the city, totaling less than 100 households. Zhang set up his headquarters at one of those castles, Zhongzhou (), while selecting 18 capable officers and sending them out to the 18 counties of the municipality other than the two in the city center, to be in charge of rebuilding their counties and welcoming the refugee population back. He simplified the laws, making murder the only capital offense, while the other offenses were punishable only by caning; he also exempted the people from taxes. As a result, the refugee population returned in droves, and he trained them in