There are two major sources for the history of the Wa and their cultural relations: their own oral legends and records about them in the written history of Han Chinese. The name of the Wa legend—Sigangli—means "coming from the cave," referring to the cave in A Wa Shan where the Wa (followed by other peoples such as Han, Lahu, and Dai) originated. This legend records the history of their migration and the origins of their agriculture, use of fire and iron tools, and religious practices. It suggests that the Wa were the original inhabitants of this mountain region, that they went through a transition from a hunting-gathering mode of production to agriculture and from a matrilineal to a patrilineal kinship system, and that for a long time they have interacted with other peoples such as Dai and Han. In the written history of Han Chinese, the earliest records relevant to the Wa are those about the Ailao and the Pu, who were the ancestors of the Wa and other peoples who resided in this region. Beginning in 109 B.C. , the Han empire established an administrative district that included the region of A Wa Shan and Wa-De'ang speakers. According to the records of the Tang dynasty (seventh to tenth centuries), the Wa had distinguished themselves from the Ailao and the Pu by their self-designation as "Vang," "Va," "Vo," or "Vu" and their mode of life as basically hunting and gathering combined with early stages of farming. Politically, the Wa were subordinate to the rule of the Nanzhao Kingdom in the Tang dynasty, and to the rule of the Dali Kingdom in the Song dynasty (mid-tenth to thirteenth centuries). From the Yuan to the early Qing dynasties (mid-thirteenth to the end of the eighteenth centuries), the Wa established many permanent villages, and agriculture became their major economic activity with hunting and gathering supplementary. This transition in their life-style was influenced by the large-scale ethnic migrations of the thirteenth to seventeenth centuries; many of the Han, Dai, and other peoples migrated to southwest Yunnan where the Wa were spreading, thus forcing the Wa to concentrate themselves in the A Wa Shan region. Those left in the outskirts of the region lived together with the newcomers, who introduced some new fanning techniques to the Wa. Since the nineteenth century, the Wa have gone through dramatic changes due to interaction with a larger cultural context. It is in this period that the Wa divided socially into three strata, became politically unified and conscious to an unprecedented degree (as shown by the famous Banhong event when seventeen Wa tribes allied into an armed force fighting the British military invaders), and took an active part in commodity production and exchange in local ethnic and international markets.