<prompt> Translate the following text to EnglishMahmud alivunja sanamu za makafiri na kuharibu mahekalu yao, lakini hata hivyo alikuwa na elimu ya kutosha kutumia nyara kujenga maktaba, makumbusho, na msikiti mzuri aliporudi Ghazni.  <response>: Mahmud smashed the infidels idols and destroyed their temples as he went, but was nonetheless cultured enough to use the booty to build a library, a museum, and a splendid mosque when he got back to Ghazni. 