Your child is having constipation
and as she is passing hard stools. Because of hard stools while passing stool there will me mucosal tear of rectum
causing sever pain and followed by secondary infection there results in severe pain
and this will cause holding of stool in further causing it hard. Its like a viscious cycle. Some times fissure develops and this causes pain while passing stool. You have to change the diet of the child by adding more dietary fibre rich foods like fruits, vegetable and raagi. Plenty of oral fluids should be take and make habit of going to toilet daily. Still problem you can give oral lactulose
syrup daily till stool softens after your doctor advise.