 The show is adapted from four of Gillian Cross (qv)s "Demon  Headmaster" novels. The first half of the first series is adapted  from "The Demon Headmaster", the second half is adapted from "The  Prime Minister"s Brain", the second series is adapted from "The  Demon Headmaster Strikes Again" and the third series is adapted from  "The Demon Headmaster Takes Over".