Dick Deadeye, or Duty Done

Queen Victoria sends Dick Deadeye (Victor Spinetti), a sailor, to recover the "Ultimate Secret" from two thieves, the Sorcerer (Peter Reeves) and his reptilian henchman, the Shameleon. They are trying to sell it to the Pirate King (George Cooper, sung Ian Samwell). At a military parade ("Entrance of the Peers"), Dick sees the Sorcerer speaking with the Pirate King. There, Nanki (John Newton, sung Casey Kelly) sees his evil twin brother Poo (same), who is picking pockets. Dick goes for backup to headquarters, the Hexagon ("Here's a how-dee-do"), finding the Captain (Peter Reeves) and the Major-General (Francis Ghent, sung John Baldry; "I am the very model of a modern major general").
Dick then goes to the pirates' lair, "The Queen's Nose" ("Oh, better far to live and die"). There, Rose Maybud (Julia McKenzie, sung Liza Strike), the barmaid, wants to find "a man of pure evil", so she can reform him. She and Dick have a moment ("Prithee, pretty maiden"), but she loses interest, since he is good. The Sorcerer and his sidekick arrive ("My name is John Wellington Wells"). The Pirate King finalizes the deal to buy the Secret for a modest sum of pirate booty, and the Sorcerer goes to get it, followed by Dick.
Dick arrives at the Sorcerer's shop and asks for a potion to make him handsome ("Sprites of earth and air") and makes a grab for the Secret, but it falls through the window into the basket of Little Buttercup (Miriam Karlin), a buxom seller of ribbons, laces and marine supplies. Poo steals the basket, and everyone chases him, including three policemen ("A policeman's lot is not a happy one"), but they mistake Nanki for Poo and arrest him. The Judge at his trial (Barry Cryer, "All hail great Judge"; "Now, Jurymen, hear my advice") flirts with Little Buttercup ("I'm called Little Buttercup"), ignores Nanki's evidence ("A wandering minstrel I" and "I swear to tell the truth" based on "When I go out of door"), sentences Nanki to 200 years in the Tower of London ("A Judge is he, and a good judge too") and leaves with Little Buttercup.
At the Tower, Nanki muses on his lot and lost love ("Farewell my love"). The spirit of Yum-Yum (Linda Lewis, sung Beth Porter) is trapped in Nanki's shamisen ("Just as the moon must have the sun", based on "The sun whose rays") and needs Nanki "to make me a whole woman". Poo is willing to return the Secret to the Sorcerer in exchange for learning his tricks, but the pirates drag them to "The Queen's Neck". The Secret in code, and the Sorcerer must decipher it. Since Poo is "the most evil man in the world", Rose decides her love for him and intends to reform him. Meanwhile, at the Hexagon, Dick sees the Rear-Admiral (Francis Ghent, sung John Baldry; "I am the monarch of the sea") and his sisters and his cousins and his aunts. He gives the Captain ("He remains an Englishman") command of the 'Pinafore' and allows Dick to recruit a crew from the prisoners, and at the Tower, Nanki sings for the prisoners ("The flowers that bloom in the spring": Prisoner sung by Ian Samwell), who nearly all enlist.
The Sorcerer and Poo are on the pirate ship ("Pour, oh pour the pirate sherry"). Rose Maybud, disguised as a pirate, sneaks aboard. Meanwhile, the Captain, accompanied by the Judge, Major-General, Rear-Admiral takes command of the 'Pinafore' ("When I was a lad"; "We sail the ocean blue"; and "I am the Captain of the Pinafore"). They pursue the pirate ship, assisted by two giant cherubs ("Go, ye heroes"); meanwhile Poo overfeeds the Sorcerer who gets seasick and hands over the Secret. When the two crews meet, they greet each other warmly. The Pirate King fights the Captain, but the King's trousers fall, and the strawberry birthmark on his backside is seen. Little Buttercup has a secret ("A many years ago"); as a wetnurse, she mixed up the infant Pirate King and the Captain (recognizable by the birthmark).
Poo sails to the nearby island of Utopia with the Secret, now pursued by everyone ("With cat-like tread"). He meets the Regent of Utopia, the Princess Zara (Miriam Karlin) and her court of show-girls. They all sing ("Hail, hail, and how-dee-do", based on "With cat-like tread"; "Land of sand and sea and sun", in the style of The Beach Boys). Zara has Poo arrested. The Sorcerer regains the Secret and is chased by Dick and the Captain. They find that the Secret is in mirror-writing, and decipher it: "It's love that makes the world go round" ("If you go in"). Nanki and Poo combine into a person composed of both good and evil. The shamisen releases the spirit of Yum Yum (the Queen of Utopia). The Sorcerer falls in love with Little Buttercup, while Rose Maybud and Dick are reunited. Once the Secret is out, war and crime cease around the world ("Here's a how-dee-do") and all live happily ever after ("Entrance of the Peers", reprise).

Question: Where is the spirit of Yum-Yum trapped?
Answer: In Nanki's shamisen