Nominalization of tausend. The interjection is short either for potz tausend Teufel (16th century) or for Middle High German tūsentlisteler, later Tausendkünstler (“the devil as a master of a thousand ruses, arts”).
Improve your pronunciation
Practice speaking and memorizing "Tausend" and many other words and sentences in German.