A couple accused of killing their six children in a house fire in Derby did so as part of a plan "that went horribly wrong", a court has heard.
Prosecutor Richard Latham said Mick and Mairead Philpott, along with friend Paul Mosley, started the fire on Victory Road by dousing the hallway with petrol and setting it alight.
Latham alleged that Mr Philpott, 56, had boasted about starting a fire in his home in an attempt to frame his mistress, 28-year-old Lisa Willis, who had previously been living at the property with her five children.
At the time of the blaze Mr Philpott was battling Willis for custody of her children, four of whom were his. According to Latham, he had "told people he had a plan up his sleeve and that she wasn't going to get away with [taking the children] - watch this space."
The also court heard that Mr Philpott had already told police Ms Willis was threatening to kill him in an attempt to support his custody claim.
Mr Philpott and his wife, 31, are accused along with Mosley, 46, of starting the fire on 11 May.
Jade Philpott, 10, and her brothers John, nine, Jack, eight, Jesse, six and Jayden, five, all died in the fire at their home in Allenton. The eldest, Duwayne, 13, died three days later in hospital.
All three defendants deny the six separate charges of manslaughter against them.
The court heard how the home was not a conventional one, with three adults and 11 children all living together.
Mr and Mrs Philpott's six children lived side by side with the four children from the former's affair with Willis. The eleventh child was Willis's by another man.
Willis, who had shared a caravan with Mr Philpott outside the house while Mrs Philpott slept in the living room or the conservatory inside, eventually moved out with her children on 11 February, three months before the deadly blaze.
Latham said that "he [Mr Philpott] often expressed the view he preferred his relationship with Lisa Willis to that he had with his wife Mairead" before she moved out.
"He had spoken of divorcing Mairead - not separating from her but divorcing her - in order that he could make Lisa Willis his wife.
"He wanted to change their status but he wanted them both to still live in the house."
Willis left with her children on the pretense of taking them swimming.
"She knew that to simply announce to Michael Philpott that she found the relationship set-up unacceptable would provoke a singularly unpleasant reaction. He was the one who made the decisions, the women did not."
Mr Philpott and Willis had been due in court on the morning of the fire to discuss custody of Willis's five children.
Latham told the jury that the three defendants are not accused of murder and the prosecution "do not suggest" there was an intention to kill the children. Instead, he told the jury: "This was a plan that went horribly wrong and resulted in total tragedy.
"What is alleged is that these children died as a result of the unlawful acts of these defendants who, we say, were acting together in a joint enterprise, setting a house fire.
"They are criminally responsible for the deaths as a result of setting the fire for some motive, for some other perceived advantage."
Latham told the jury it was a "whodunnit trial" and the jury needs to decide if this was "an inside job or an attack from outside?"
The trial is expected to last for six weeks.