Net distance covered in 8s = 2m
At the end of 24s , he will be 6m away from the starting point and 5m away from the pit.
Now , again he will take 5 steps forward
And , as soon as he will take the fifth step , he will fall into the pit
So , total time : 24+5= 29s