QAYYARA, Iraq (REUTERS) - 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 in Iraq and Syria (ISIS) 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.
ISIS was driven from the town three months ago in the early stages of a campaign to recapture the city of Mosul, which lies about 60km to the north and is now under assault by Iraqi security forces backed by a US-led coalition.
As ISIS' 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 ISIS 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, ISIS 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 ISIS' 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 Mr 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 Mr Mahjoub, whose school was hit by an air strike several months ago. "Children are malleable; you can change their opinion and beliefs quickly."
Mr 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.
Missing from the classroom in the girls' school are dozens of pupils whose male relatives were associated with ISIS and are no longer welcome in Qayyara. Mr Mahjoub said around 10 of his own students had joined the militants.
Behind the school are the remains of a car bomb that has yet to be removed and the sky is dark with smoke from oil wells the militants set ablaze, making it hard to breathe and turning sheep black.
On a nearby street, a group of boys coughing from the smoke described what they had seen under ISIS, including the bodies of its opponents strung up in public places as an example to others.
Dancing and singing the same Iraqi patriotic songs blaring from passing military convoys, 11-year-old Thamer paused to describe how a local ISIS member called Abu Suleiman had been lynched after Iraqi forces recaptured the town.
The man's brain and heart spilled out of his body, said Thamer in a high-pitched voice. "They took revenge on him," he said. "It was right. We were happy."