What mercenaries captured Hamadan in the 10th century?