What dynasty ended in the 10th century?