For what primes $p$ and positive integers $k$ is this algebraic expression divisible by $3$? My initial question is as is in the title:

For what prime $p$ and positive integers $k$ is this algebraic expression divisible by $3$?
$$A(p,k):=\dfrac{p^{2k+2} - 4p^{2k+1} + 6p^{2k} + 2p^{k+1} - 8p^k + 3}{2(p - 1)^2}$$

I would like to qualify that I am specifically interested in those values for $p$ and $k$ satisfying the congruence $p \equiv k \equiv 1 \pmod 4$.
MY ATTEMPT
Here, I will evaluate my expression for
$$p_1 = 5, k_1 = 1,$$
which gives $A(p_1,k_1)=9$ (which is divisible by $3$),
$$p_2 = 13, k_2 = 1,$$
which gives $A(p_2,k_2)=73$ (which is not divisible by $3$), and
$$p_3 = 17, k_3 = 1,$$
which gives $A(p_3,k_3)=129$ (which is divisible by $3$).
Here is my final question:

Will it be possible to consider the cases $p \equiv 1 \pmod 3$ and $p \equiv 2 \pmod 3$ separately, then use the Chinese Remainder Theorem afterwards?  (I know the concept, but I would have forgotten how to do that.)

CONJECTURE: If $p \equiv 2 \pmod 3$, then $3 \mid A(p,k)$.
Alas, this is where I get stuck.
 A: *

*If $p\equiv 2\pmod 3$, then the numerator of $$A(p,k)=\dfrac{p^{2k+2} - 4p^{2k+1} + 6p^{2k} + 2p^{k+1} - 8p^k + 3}{2(p - 1)^2}$$ is divisible by $3$ while the denominator is not divisible by $3$, so $3\mid A(p,k)$.


*If $p\equiv 1\pmod 3$, then since $p$ can be written as $p=12m+1$, we have $$A(p,k)=\dfrac{1+(8 m - 2) (12 m + 1)^k + (48m^2 - 8 m  + 1) (12 m + 1)^{2 k} }{96m^2}$$Now, we have, by the binomial theorem,$$\begin{align}&1+(8 m - 2) (12 m + 1)^k + (48m^2 - 8 m  + 1) (12 m + 1)^{2 k} 
\\\\&=1+(8 m - 2)\sum_{i=0}^{k}\binom{k}{i}(12m)^i + (48m^2 - 8 m  + 1)\sum_{i=0}^{2k}\binom{2k}{i}(12m)^{i}
\\\\&=1+(8 m - 2)\bigg(1+12km+\underbrace{\sum_{i=2}^{k}\binom{k}{i}(12m)^i}_{\text{divisible by $288m^2$}}\bigg) 
\\&\qquad\quad + (48m^2 - 8 m  + 1)\bigg(1+24km+\binom{2k}{2}(12m)^{2}+\underbrace{\sum_{i=3}^{2k}\binom{2k}{i}(12m)^{i}}_{\text{divisible by $288m^2$}}\bigg)
\\\\&\equiv 1+(8 m - 2)(1+12km)
\\&\qquad\quad+ (48m^2 - 8 m  + 1)\bigg(1+24km+\binom{2k}{2}(12m)^{2}\bigg)\pmod{288m^2}
\\\\&\equiv 48(k+1)m^2\pmod{288m^2}
\end{align}$$So, there is an integer $N$ such that $$A(p,k)=\frac{48(k+1)m^2+288m^2N}{96m^2}=3\bigg(\frac{k+1}{6}+N\bigg)$$Since $k+1$ is even, we see that $3\mid A(p,k)$ if and only if $k+1\equiv 0\pmod 3$, i.e. $k\equiv 2\pmod 3$.
In conclusion, considering $p\equiv k\equiv 1\pmod 4$, we can say that

*

*If $p\equiv 5\pmod{12}$, then $3\mid A(p,k)$.


*If $p\equiv 1\pmod{12}$ and $k\equiv 5\pmod{12}$, then $3\mid A(p,k)$.


*If $p\equiv 1\pmod{12}$ and $k\not\equiv 5\pmod{12}$, then $3\not\mid A(p,k)$.
A: Consider the point that the sum of coefficiant of numerator is 0, so for $p\equiv 1\bmod3$ the numerator is divisible by 3 for any k. For the case $p\equiv 2\bmod 3$ we have:
$p\equiv 2 \bmod 3\Rightarrow p^2\equiv 1 \bmod 3\Rightarrow p^{2(k+1)}\equiv 1 \bmod 3$
$p^{2k+1}=p^{2k}\cdot p\equiv(1\bmod 3)(2\bmod 3)\equiv 2\bmod 3\Rightarrow 4p^{2k+1}\equiv 8 \bmod 3\equiv 2 \bmod 3$
$6p^{2k}\equiv 0 \bmod 3$
$p^{k+1}p^k\cdot p\equiv (2^k \bmod 3)(2\bmod 3)\Rightarrow 2p^{k+1}\equiv 2^{k+2} \bmod 3$
$8p^k\equiv 2^{k+3} \bmod 3$
Summing these we get for numerator:
$r=1-2+0+2^{k+2}-2^{k+3}-3\equiv 2^{k+2}(1-2)-1\equiv -1-2^{k+2}\bmod 3$
$2^{k+1}=(3-1)^{k+1}$
So if $k=2m+1$ we have:
$r=-1 -3t+1=-3t\equiv 0 \bmod 3$
