Method 1: Let the length of the train be x. and time is given 12s
S=D/T , so x=S*12 --- (i)
In 2nd part, S=(x+170)/36 --- (ii)
Equating both equation,
x/12=(x+170)/36
3x=x+170
x=85m
S=85/12*(18/5) km/hr
S=25.5 km/hr
Method 2(ShortTrick):
If train cross its length in 12 seconds and 170 m bridge in (36-12) =24 seconds
So, speed = (170/24) * (18/5)=25.5 km/hr