Any wish of yours granted if you can reverse fate of a dying empire/kingdom

A mysterious deity comes up to you with an offer. It will grant you any wish that you desire, no strings attached, if you're able to reverse the fate of a dying empire in the past and protect its legacy.

The deity offers you the following rules:

  1. You will be "isekaied" to take position as the last ruler of the empire/kingdom, and assume the ruler's identity
  2. You will retain all knowledge from your current life and the knowledge of the deal
  3. You will start your deal 10 years before the ruler's death
  4. You are given 24 hours to prepare and conduct as much research as you want, but you're only allowed to bring one sheet of A4 paper (which you can write on) with you.
  5. Your task, once you take the ruler's place, is to change history and reverse the impending doom that the empire/kingdom faces. For example, as the final Tsar of Russia, Emperor Puyi of the Qing Dynasty.
  6. Not only must you avoid the impending doom, you must ensure that the empire/kingdom will at least outlive one generation of your offspring. Ie, your children must rule peacefully until they die of natural causes. Death by any violent means such as assassination will render the deal moot.
  7. You can only choose a pre-1900 civilisation.
  8. Once you die in the past, you'll be teleported back straight to when you left in the present. Should you and your children be successful, you'll immediately get 1 wish in the present, no questions asked.

Now, the big decision, would you accept this offer and if yes, which civilization would you choose and how you'll go about fulfilling the conditions?