(CNN) Fifty-one children and three teachers were injured at a kindergarten in southwest China when a man attacked them with a corrosive chemical, state media reported Tuesday.

According to state-run news agency Xinhua, a 23-year-old suspect surnamed Kong climbed into the school in Kaiyuan city, Yunnan province, on Monday afternoon and sprayed caustic soda on a room full of students and teachers.

Two of those hit were seriously hurt, although their injuries are not life-threatening, the report said.

The suspect was detained about an hour after the attack. He allegedly sprayed the chemical as an act of revenge on society, Xinhua quoted police as saying.

Caustic soda -- also known as sodium hydroxide -- is used in the manufacturing of a number of common products, including soap, paper, and various dyes.