The sum to $n$ terms of an AP is of the form $\lambda(An^2+Bn)$, (where $A,B, \lambda$ are constants) although when taking ratios for the sums for two APs, $n, \lambda$ cancel out, giving $\frac{^1An+^1B}{^2An+^2B}$. The ratio of the $n$-th terms can be derived by considering the ratio of the differences between the sum to $n$ terms and sum to $(n-1)$ terms respectively, based on the given ratio of sums but first adjusting for the point described above.
$$\begin{align}
\frac {^1u_n}{^2u_n}&=\frac{^1S_n-^1S_{n-1}}{^2S_n-^2S_{n-1}}\\
&=\frac{\color{blue}n[7n+1]-\color{blue}{(n-1)}[7(n-1)+1]}{\color{blue}n[4n+27]-\color{blue}{(n-1)}[4(n-1)+27]}\\
&=\frac{7[n^2-(n-1)^2]+1}{4[n^2-(n-1)^2]+27}\\
&=\frac{7(2n-1)+1}{4(2n-1)+27}
\color{lightgrey}{=\frac{7N+1}{4N+27}=\frac {^1S_{N}}{^2S_N}}\\
&=\color{red}{\frac {14n-6}{8n+23}}\end{align}$$
Note that, as also pointed out in other solutions posted earlier, this is the same as the ratio of the sum to $N$ terms of the two APs where $N=2n-1$.