The Three Departments and Six Ministries were the core of central government under the Sui and Tang, the most mature organizational form of the Chinese imperial state. The three departments: the Secretariat drafted edicts (decision), the Chancellery reviewed and could return them (deliberation), and the Department of State Affairs executed; their heads jointly served as chancellors, so that the chancellor's power was divided in three and gathered in the emperor; under the Department of State Affairs were the six ministries — Personnel, Revenue, Rites, War, Justice and Works — directing the country's administration. The system grew out of the Han-Wei imperial secretariat and the Southern Dynasties evolution; Emperor Wen of Sui fixed it in 581 and the Tang perfected it: the Hall of Government Affairs (later the Secretariat-Chancellery) was where chancellors deliberated, and examination graduates entered the ministries through selection. Its merits were procedural decision-making, departmental specialization and mutual checks among chancellors, reducing the damage of emperor–chancellor conflict; the six-ministry division was inherited by Song, Yuan, Ming and Qing (the Ming abolished the Secretariat and made the ministries report directly to the emperor; the Qing Grand Council added a variant), and its influence reached Japan's Taika Reform and the Joseon bureaucracy. It marks the maturity of China's civil service: government changed from a minister's personal staff into a departmental machine with clear division of labour.