Ok, there is a guy confined in a very lonely place, in very far plane, with a friendly noble djinn.
The guy can't escape just asking a wish, but he has to solve several "puzzles" by reading arcane and divine scrolls in this place.
There's no way to duplicate those spells, the guy or the djinn...