QAYYARA, Iraq - The school walls have a fresh coat of paint and classrooms are crammed, but it will take longer to undo the damage done to thousands of Iraqi children who lived under Islamic State for more than two years.
Although the school term began officially in September, only this week have pupils in the northern town of Qayyara been re-issued with standard Iraqi textbooks, which the militants replaced with their own in an attempt to brainwash a generation.
Islamic State was driven from the town three months ago in the early stages of a campaign to recapture the city of Mosul, which lies about 60 km to north and is now under assault by Iraqi security forces backed by a US-led coalition.
As Islamic State's self-proclaimed caliphate is eroded, a clearer picture is emerging of the group's project and the enduring mark left on those who lived through it.
"We are happy to be back at school," said eight-year-old Iman, who like most of her classmates stopped attending classes after Islamic State took control. "They wanted us to come but we didn't want to because we don't know how to study in their language, the language of violence."
When the militants overran the area in the summer of 2014, they allowed schools to run as normal, local people said. But later they banned subjects they considered un-Islamic such as geography, history and civic education, and used boys' schools as a recruiting ground.
The following school year, beginning in 2015, Islamic State imposed an entirely new curriculum to inculcate children with their ideology. Maths exercises were expressed in terms of weapons and ammunition: "one bullet plus two bullets equals how many bullets?".
At that point, most parents stopped sending their children to school, and many pupils who were old enough to make up their minds left voluntarily.
As a result, most children have been set back by two grades, and since some teachers have been displaced by the violence, there is only one teacher for roughly every 80 pupils at the girls' school in Qayyara.
"They have forgotten their lessons... Now we are reminding them," said their teacher Maha Nadhem Kadhem, pacing around the classroom, in which four girls are squeezed onto each bench made for two. "We don't want them to be illiterate and ignorant."
The headmistress, who asked to remain unnamed, said Islamic State's vice squad known as the Hisba had made regular visits to the school to ensure compliance with the group's strict dress code for women and girls.
Others such as Farouq Mahjoub, the assistant headmaster of a secondary school for boys in Qayyara, said he had been threatened with death unless he turned up to work, even though no pupils came to class by the end.
"The biggest impact is on children," said Mahjoub, whose school was hit by an airstrike several months ago. "Children are malleable; you can change their opinion and beliefs quickly."
Mahjoub said children behaved more aggressively than before, and that the games they play now are violent, estimating it would take no less than five years to reverse the damage, even if a plan to rehabilitate them was put into effect.