Ibn Sina subsequently settled at Rey, in the vicinity of modern Tehran, the home town of Rhazes; where Majd Addaula, a son of the last Buwayhid emir, was nominal ruler under the regency of his mother (Seyyedeh Khatun). About thirty of Ibn Sina's shorter works are said to have been composed in Rey. Constant feuds which raged between the regent and her second son, Shams al-Daula, however, compelled the scholar to quit the place. After a brief sojourn at Qazvin he passed southwards to Hamadãn where Shams al-Daula, another Buwayhid emir, had established himself. At first, Ibn Sina entered into the service of a high-born lady; but the emir, hearing of his arrival, called him in as medical attendant, and sent him back with presents to his dwelling. Ibn Sina was even raised to the office of vizier. The emir decreed that he should be banished from the country. Ibn Sina, however, remained hidden for forty days in sheikh Ahmed Fadhel's house, until a fresh attack of illness induced the emir to restore him to his post. Even during this perturbed time, Ibn Sina persevered with his studies and teaching. Every evening, extracts from his great works, the Canon and the Sanatio, were dictated and explained to his pupils. On the death of the emir, Ibn Sina ceased to be vizier and hid himself in the house of an apothecary, where, with intense assiduity, he continued the composition of his works.
Try to answer this question if possible (otherwise reply "unanswerable"): Where did Ibn Sina write his first thirty works?
unanswerable