At the top of Mount Munch lives a group of people known as the Hyups. One of their numbers, a Munchkin named Bini Aru, discovered a method of transforming people and objects by merely saying the word "Pyrzqxgl". After Princess Ozma decreed that no one could practice magic in Oz except for Glinda the Good Witch and the Wizard of Oz, Bini wrote down the directions for pronouncing "Pyrzqxgl" and hid them in his magical laboratory.
When Bini and his wife are at a fair one day, their son Kiki Aru, who thirsts for adventure, finds the directions and afterwards transforms himself into a hawk and visits various countries outside the land of Oz. When he alights in the land of Ev, Kiki Aru learns that he needs money to pay for a night's lodging (versus Oz, where money is not used at all) and changes himself into a magpie to steal a gold piece from an old man. A sparrow confronts the then-human Kiki Aru with knowledge of the theft, and Kiki says that he did not know what it was like to be wicked before, he is glad that he is now. This conversation is overheard by Ruggedo, the Nome who was exiled to the Earth's surface in Tik-Tok of Oz, and he sees through Kiki Aru's power a chance to get revenge on the people of Oz.
Kiki changes himself and Ruggedo into birds and they fly over the Deadly Desert into the Land of Oz. They enter Oz as animals to escape detection by Glinda and to recruit an army of conquest from the country's wild animal population. When they first appear in the Forest of Gugu in the Gillikin Country, Kiki changes himself and Ruggedo into Li-Mon-Eags (fictional creatures with the heads of lions, the bodies of monkeys, and the wings of eagles as well as having the tails of donkeys) and lies that they've seen the people of the Emerald City plan to enslave the animal inhabitants of the Forest. Ruggedo claims that they the Li-Mon-Eags will transform the animals into humans and march on the Emerald City and transform its inhabitants into animals, driving them into the forest. Ruggedo proves their power (for Kiki's the only one who knows "Pyrzqxgl") by having Kiki transform one of the leopard king Gugu's advisors, Loo the unicorn, into a man and back again. Gugu offers to meet with the leaders of the other animal tribes to decide on this matter of invasion.
Dorothy and the Wizard arrive with the Cowardly Lion and the Hungry Tiger in the Forest of Gugu during this council of war with a request for monkeys to train in time for Ozma's upcoming birthday party. Ruggedo recognizes his old enemies and inspires Kiki to begin transforming people and animals left and right   including Ruggedo, whom Kiki turns against by transforming him into a goose, a transformation that the Nome most fears because as a goose he might lay an egg. (In Baum's universe, all eggs are deadly poison to nomes.)
The Wizard, whom Kiki transformed into a fox, follows the Li-Mon-Eag with his magic bag, the transformed Kiki, deep into the forest where he begins transforming monkeys into giant human soldiers. However, Kiki makes them so big that they cannot move through the trees. The Wizard, however, heard how to correctly pronounce "Pyrzqxgl" and first stops Kiki and Ruggedo by transforming them into a walnut and a hickory nut. Then the Wizard resumes his rightful form and changes Dorothy, the Cowardly Lion, the Hungry Tiger, and Gugu back to their forms, and he agrees to change the soldiers back into monkeys. The Wizard recruits several of the grateful monkeys and shrinks them down to bring back to the Emerald City and train.
On arriving there, Dorothy and the Wizard are dispatched to a magic island where Cap'n Bill and Trot went to get a magic flower for Ozma's birthday. However, the island itself causes anything living that touches it to take root there, and that is how the sailor and his friend are found when Dorothy and the Wizard arrive. The Wizard uses "Pyrzqxgl" to change Cap'n Bill and Trot into honeybees which narrowly avoid being eaten by the Cowardly Lion and the Hungry Tiger. When they are human again, Cap'n Bill retrieves the flower by strapping a wood plank onto his good leg, walks with that and his wooden leg onto the island, and retrieves the flower.
Back at the Emerald City, Ozma and her friends celebrate her birthday (though without quite the pomp and fanfare from The Road to Oz) and then decide how to deal with the evil magicians transformed into nuts. The Wizard uses "Pyrzqxgl" to change them back to Kiki Aru and Ruggedo and make them thirsty enough to drink the Water of Oblivion, which will make them forget all that they have ever known. The now-blank slate Kiki Aru and Ruggedo will live in the Emerald City and learn to be good and kind.
Output: Who did Ruggedo want revenge on?