China emerged as one of the world's first civilisations in the fertile basin of the Yellow River in the North China Plain. China was one of the world's foremost economic powers for most of the two millennia from the 1st until the 19th century. For millennia, China's political system was based on absolute hereditary monarchies, or dynasties, beginning with the semi-legendary Xia dynasty in 21st century BCE. Since then, China has expanded, fractured, and re-unified numerous times. In the 3rd century BCE, the Qin reunited core China and established the first Chinese empire. The succeeding Han dynasty (206 BCE – 220 CE) saw some of the most advanced technology at that time, including papermaking and the compass, along with agricultural and medical improvements. The invention of gunpowder and movable type in the Tang dynasty (618 – 907) and Northern Song Dynasty (960 – 1127) completed the Four Great Inventions. Tang culture spread widely in Asia, as the new Silk Road brought traders to as far as Mesopotamia and the Horn of Africa. The Qing Empire, China's last dynasty, which formed the territorial basis for modern China, suffered heavy losses to foreign imperialism.