Given the following context:

After usurping the throne of the Later Zhou dynasty, Emperor Taizu of Song (r. 960–976) spent sixteen years conquering the rest of China, reuniting much of the territory that had once belonged to the Han and Tang empires and ending the upheaval of the Five Dynasties and Ten Kingdoms period. In Kaifeng, he established a strong central government over the empire. The establishment of this capital marked the start of the Northern Song period. He ensured administrative stability by promoting the civil service examination system of drafting state bureaucrats by skill and merit (instead of aristocratic or military position) and promoted projects that ensured efficiency in communication throughout the empire. In one such project, cartographers created detailed maps of each province and city that were then collected in a large atlas. Emperor Taizu also promoted groundbreaking scientific and technological innovations by supporting such works as the astronomical clock tower designed and built by the engineer Zhang Sixun.The Song court maintained diplomatic relations with Chola India, the Fatimid Caliphate of Egypt, Srivijaya, the Kara-Khanid Khanate of Central Asia, the Goryeo kingdom in Korea, and other countries that were also trade partners with Japan. Chinese records even mention an embassy from the ruler of "Fu lin" (拂菻, i.e. the Byzantine Empire), Michael VII Doukas, and its arrival in 1081. However, China's closest neighbouring states had the greatest impact on its domestic and foreign policy. From its inception under Taizu, the Song dynasty alternated between warfare and diplomacy with the ethnic Khitans of the Liao dynasty in the northeast and with the Tanguts of the Western Xia in the northwest. The Song dynasty used military force in an attempt to quell the Liao dynasty and to recapture the Sixteen Prefectures, a territory under Khitan control since 938 that was traditionally considered to be part of China proper (Most parts of today's Beijing and Tianjin). Song forces were repulsed by the Liao forces, who...

answer the following question:

Who did the Song Dynasty alternate between warfare and diplomacy with? 

the Tanguts of the Western Xia