If you book from Ndls to Cnb you would get a seat in S5 as it belongs to CNB quota and from CNB to Gaya you would get seat in S5 only. So you have to you change your seat in the same coach
I did the same in Mahabodhi two days ago and availed confirm tickets.