Hint:
Observe that for $n=0,1,\cdots5$, you are given $P(3^n)=n$.
The resolution by Cramer yields, for the first degree coefficient
$$\frac{\left|\begin{matrix}
3^0&0&3^0&3^0&3^0&3^0\\
3^0&1&3^2&3^3&3^4&3^5\\
3^0&2&3^4&3^6&3^8&3^{10}\\
3^0&3&3^6&3^9&3^{12}&3^{15}\\
3^0&4&3^8&3^{12}&3^{16}&3^{20}\\
3^0&5&3^{10}&3^{15}&3^{20}&3^{25}
\end{matrix}\right|}
{\left|\begin{matrix}
3^0&3^0&3^0&3^0&3^0&3^0\\
3^0&3^1&3^2&3^3&3^4&3^5\\
3^0&3^2&3^4&3^6&3^8&3^{10}\\
3^0&3^3&3^6&3^9&3^{12}&3^{15}\\
3^0&3^4&3^8&3^{12}&3^{16}&3^{20}\\
3^0&3^5&3^{10}&3^{15}&3^{20}&3^{25}
\end{matrix}\right|}.$$
The denominator is of the Vandermonde type and equals $(3^5-3^4)(3^5-3^3)(3^5-3^2)(3^5-3^1)(3^5-3^0)(3^4-3^3)(3^4-3^2)(3^4-3^1)(3^4-3^0)(3^3-3^2)(3^3-3^1)(3^3-3^0)(3^2-3^1)(3^2-3^0)(3^1-3^0)$.