Suppose that the angles of $\triangle ABC$ satisfy $\cos(3A)+\cos(3B)+\cos(3C)=1.$ Two sides of the triangle have lengths 10 and 13. There is a positive integer $m$ so that the maximum possible length for the remaining side of $\triangle ABC$ is $\sqrt{m}.$ Find $m.$
Note that $\cos{3C}=-\cos{(3A+3B)}$. Thus, our expression is of the form $\cos{3A}+\cos{3B}-\cos{(3A+3B)}=1$. Let $\cos{3A}=x$ and $\cos{3B}=y$.
Using the fact that $\cos(3A+3B)=\cos 3A\cos 3B-\sin 3A\sin 3B=xy-\sqrt{1-x^2}\sqrt{1-y^2}$, we get $x+y-xy+\sqrt{1-x^2}\sqrt{1-y^2}=1$, or $\sqrt{1-x^2}\sqrt{1-y^2}=xy-x-y+1=(x-1)(y-1)$. 
Squaring both sides, we get $(1-x^2)(1-y^2) = [(x-1)(y-1)]^2$. Cancelling factors, $(1+x)(1+y) = (1-x)(1-y)$.

Notice here that we cancelled out one factor of (x-1) and (y-1), which implies that (x-1) and (y-1) were not 0. If indeed they were 0 though, we would have
$cos(3A)-1=0, cos(3A)=1$
For this we could say that A must be 120 degrees for this to work. This is one case. The B case follows in the same way, where B must be equal to 120 degrees. This doesn't change the overall solution though, as then the other angles are irrelevant (this is the largest angle, implying that this will have the longest side and so we would want to have the 120 degreee angle opposite of the unknown side).
Expanding, $1+x+y+xy=1-x-y+xy\rightarrow x+y=-x-y$. 
Simplification leads to $x+y=0$.
Therefore, $\cos(3C)=1$. So $\angle C$ could be $0^\circ$ or $120^\circ$. We eliminate $0^\circ$ and use law of cosines to get our answer: 
\[m=10^2+13^2-2\cdot 10\cdot 13\cos\angle C\]
\[\rightarrow m=269-260\cos 120^\circ=269-260\left(\text{-}\frac{1}{2}\right)\]
\[\rightarrow m=269+130=399\]
$\framebox{399}$