Some children shared some chocolate bars among themselves. They tried taking 9 chocolate bars each, but found that the last child had only 8 chocolate bars. When each child took 4 chocolate bars, there were 39 chocolate bars left over. How many chocolate bars were there in all?