Let the first term of a series be \( T_1 = 6 \) and its \( r^{\text{th}} \) term \( T_r = 3T_{r-1} + 6^r, \; r = 2, 3, \ldots, n \). If the sum of the first \( n \) terms of this series is \( \frac{1}{5}\left(n^2 - 12n + 39\right)\!\left(4\cdot 6^n - 5\cdot 3^n + 1\right) \), then \( n \) is equal to ________.