If $271|a,271|(a^{31x}-a)$ for integer $x>0$
Else $(271,a)=1\implies 271|(a^{31x}-a)\iff 271(a^{31x-1}-1)$
Now as $271$ is prime, it has at least one primitive root,
the highest $ord_{271}(a)$ will be $271-1=270$ and the order of other numbers will be divisor of $270$
$\implies 270$ must divide $31x-1\iff 31x\equiv1\pmod {270}$
Now, $$\frac{270}{31}=8+\frac{22}{31}=8+\frac1{\frac{31}{22}}=8+\frac1{1+\frac9{22}}$$
$$=8+\frac1{\frac{31}{22}}=8+\frac1{1+\frac1{\frac{22}9}}=8+\frac1{1+\frac1{2+\frac49}}=8+\frac1{1+\frac1{2+\frac1{\frac94}}} =8+\frac1{1+\frac1{2+\frac1{2+\frac14}}}$$
So, the previous convergent of $\frac{270}{31}$ is $$8+\frac1{1+\frac1{2+\frac1{2}}}=\frac{61}7$$
Using Theorem $3$ of this,
$$ 31\cdot 61 -270\cdot7=1\implies 31\cdot61\equiv1\pmod{270} $$
$$\implies x\equiv61\pmod{270}$$