3. For the sequence $\left\{a_{n}\right\}$, $a_{1}=1$, and it satisfies $a_{n+1}=3 a_{n}+2 n-1(n=1,2, \cdots)$. Find the general term formula
3. Convert the recurrence relation into a first-order difference equation: $f(x+1)=3 f(x)+2 x-1, f(1)=1$. Its characteristic root is 3, let $g(x)=$ $2 x-1$, assume a particular solution $R(x)=A x+B$, substitute into the equation, $A(x+1)+B=3(A x+B)+2 x-1$. After rearranging and comparing the coefficients of the same powers on both sides of the equation, we get: $\left\{\begin{array}{l}A=3 A+2, \\ A+B=3 B-1,\end{array}\right.$ Solving these, we find $A=-1, B=0$, so the general solution is $f(x)=c \cdot 3^{x}-x$. Given $f(1)=1$, we have $3 c-1=1$, thus $c=\frac{2}{3}$. Therefore, the general term of the sequence is $a_{n}=\frac{2}{3} \cdot 3^{n}-n$.