Good day everyone

I am in need of help, I was using an online program to solve a sequence, the name of the program is WolframAlpha and using it I was able to get the actual nth term that I was looking for several times. But in order to get that nth term the program used the following generating function

$$\frac{ z(-34z ^ { 2 } +77z-41) }{ (z-1) ^ { 3 } } +25$$

Note my sequence was **25,32,36,39,41** and gave me nth term ***42*** which is what I actually needed.
Now I need to find out how did the program get to find the nth using this generating function, I don't understand how -34z and 77z came to be.

Thank you while I wait for the answer