Famine, revolt, and the dynastic cycle