\section{A congruence modulo \texorpdfstring{$p$}{p}}\label{sec:3} The following congruence describes $J_n$ modulo $p$ in terms of smaller orders. It is the polynomial behind the divisibility results of Stones and Wanless \cite{SW10, SW12} and behind the cases of Drisko and Glynn. Put $J_0 = 1$. \begin{theorem}\label{thm:3.1} Let $p$ be a prime and $m \ge 0$. Then, coefficientwise modulo $p$, \[ J_{p+m}(t) \equiv J_p(t+m)\, J_m(t)\, (t^p - t)^m \pmod p . \] Moreover $J_p(t) \equiv \sum_{\tau} \prod_{C} f(V_C) \pmod p$, where $\tau$ runs over the permutations of $\Z_p$, $C$ over the cycles of $\tau$, $V_C \in \Z_p$ is the sum of the elements of $C$, and $f(V) = t^p$ if $V = 0$ and $f(V) = t$ otherwise. \end{theorem} The idea is to let a cyclic group of order $p$ rotate $p$ of the vertices. Orbits of length $p$ vanish modulo $p$, and the fixed transition systems have a simple structure: the remaining $m$ vertices behave like an independent copy of $K_m^\circ$, and each of them contributes a factor $t^p - t$ after summing over a shift in $\Z_p$. Figure~\ref{fig:lucas} shows the contraction of the arcs through $M$ for $p = 5$ and $m = 2$. \begin{figure}[ht] \centering \input{figures/lucas} \caption{The fixed transition systems in the proof of Theorem~\ref{thm:3.1} for $p = 5$ and $m = 2$. Left: the vertices of $\Z_5$, rotated by $\rho$, and $M = \{w_1, w_2\}$; a fixed system maps $(a, w_1)$ to $(w_1, a + \kappa_{w_1})$, and the passage $0 \to w_1 \to 2$ (dotted, $\kappa_{w_1} = 2$) is replaced by one arc of class $w_1$. Right: after the contraction every vertex of $\Z_5$ has one entering and one leaving arc of each class, shown here for the class $w_1$ and the class $\delta = 1$.} \label{fig:lucas} \end{figure} \begin{proof} Let $V = \Z_p \sqcup M$ with $|M| = m$, and let $A = V \times V$ be the arc set of $K_{p+m}^\circ$. A transition system is a permutation $\Phi$ of $A$ such that each arc $e = (u,v)$ is mapped to an arc leaving $v$, and $c(\Phi)$ is its number of cycles. Let $\rho$ act on $V$ by $x \mapsto x+1$ on $\Z_p$ and trivially on $M$. It acts on $A$, and by conjugation on transition systems, preserving the number of cycles. Orbits have length $1$ or $p$, so $J_{p+m}(t)$ is congruent modulo $p$ to the sum of $t^{c(\Phi)}$ over the systems with $\rho\Phi\rho^{-1} = \Phi$. Let $\Phi$ be fixed by $\rho$. The arcs fixed by $\rho$ are those of $A_M = M \times M$. If $e \in A_M$, then $\Phi(e)$ is fixed by $\rho$, so $\Phi$ maps $A_M$ to itself, and its restriction is an arbitrary transition system of $K_m^\circ$ on $M$. The other arcs are permuted among themselves. For $w \in M$, the arcs $(a,w)$ with $a \in \Z_p$ are mapped to arcs $(w,c)$ with $c \in \Z_p$, and $\Phi(a+1,w) = \rho\Phi(a,w)$ forces $\Phi(a,w) = (w, a+\kappa_w)$ for some $\kappa_w \in \Z_p$. At the vertices of $\Z_p$, $\Phi$ is determined by its bijection at the vertex $0$, which is arbitrary. Replace each passage $a \to w \to a + \kappa_w$ by a single arc of \emph{class} $w$ from $a$ to $a + \kappa_w$, and give the arc $(a, a+\delta)$ with $\delta \in \Z_p$ the class $\delta$. This does not change the number of cycles. Every vertex of $\Z_p$ now has one entering and one leaving arc of each class in $\Gamma = \Z_p \sqcup M$, and the bijection at $0$ is a permutation $\pi$ of $\Gamma$. Thus the fixed systems correspond to the triples (system on $K_m^\circ$, $\kappa \in \Z_p^M$, $\pi \in \operatorname{Sym}(\Gamma)$); conversely each triple defines a fixed system, and different triples give different systems. The cycle count is the sum of the counts of the two parts. Give the class $x$ the displacement $\delta_x = x$ for $x \in \Z_p$ and $\delta_w = \kappa_w$ for $w \in M$. A cycle $(x_1, \dots, x_l)$ of $\pi$ with total displacement $V = \sum_i \delta_{x_i}$ describes the walks that start at some vertex $b$ with class $x_1$ and return to class $x_1$ at the vertex $b + V$. The $pl$ arcs with these classes therefore form $p$ cycles if $V = 0$, and, since $p$ is prime and so $V$ generates $\Z_p$, one cycle of length $pl$ otherwise; the contribution is $f(V)$. Hence \begin{equation}\label{eq:3.1} J_{p+m}(t) \equiv J_m(t) \sum_{\kappa \in \Z_p^M} \sum_{\pi} \prod_{C} f(V_C) \pmod p . \end{equation} For $m = 0$ this is the second statement of the theorem; call its right side $Z(t)$. Now sum over $\kappa$. Consider a cycle of $\pi$ that contains $k \ge 1$ classes from $M$. Its displacement is a fixed element of $\Z_p$ plus the sum of the $k$ shifts $\kappa_w$ of its classes, so it takes every value of $\Z_p$ exactly $p^{k-1}$ times. The cycle contributes $p^{k-1}(t^p + (p-1)t)$, which is $\equiv t^p - t$ if $k = 1$ and $\equiv 0$ if $k \ge 2$. Different cycles involve different shifts, so modulo $p$ only the permutations $\pi$ survive in which the $m$ classes of $M$ lie in different cycles, and each of these $m$ cycles gives $t^p - t$. Such a $\pi$ is described by the set $U \subseteq \Z_p$ of elements lying in the cycles through $M$, by the distribution of $U$ onto these $m$ cycles, and by a permutation $\tau$ of $\Z_p \setminus U$. Each cycle through $w \in M$ is $w$ followed by a list of elements of $U$, and there are $m(m+1)\cdots(m+|U|-1)$ ways to distribute $U$ onto $m$ labelled lists. Hence the double sum in \eqref{eq:3.1} is congruent to $(t^p - t)^m\, Y$ with \[ Y = \sum_{U \subseteq \Z_p} m(m+1)\cdots(m+|U|-1) \sum_{\tau \in \operatorname{Sym}(\Z_p \setminus U)} \prod_{C} f(V_C) . \] It remains to show $Y \equiv Z(t+m)$. Modulo $p$ one has $(t+m)^p \equiv t^p + m$, so the function $f$ for the variable $t+m$ is $f + m$. Expanding, \[ Z(t+m) \equiv \sum_{\tau \in \operatorname{Sym}(\Z_p)} \prod_C \bigl(f(V_C) + m\bigr) = \sum_{\tau} \sum_{\mathcal A} m^{|\mathcal A|} \prod_{C \notin \mathcal A} f(V_C), \] where $\mathcal A$ runs over the sets of cycles of $\tau$. Group the terms by the union $U$ of the cycles in $\mathcal A$. The cycles in $\mathcal A$ form a permutation of $U$, and $\sum_{\sigma \in \operatorname{Sym}(U)} m^{c(\sigma)} = m(m+1)\cdots(m+|U|-1)$. This gives $Y$. Since $J_p \equiv Z$ as polynomials, $J_p(t+m) \equiv Z(t+m) \equiv Y$, and the theorem follows. \end{proof} For $g_n$ the theorem reads as follows. Put $g_1 = g_2 = 1$; this agrees with Lemma~\ref{lem:2.3}, since $j_1 = 1$ and $j_2 = t$. \begin{corollary}\label{cor:3.2} Let $p$ be a prime and $m \ge 1$. Then in $\F_p[t]$ \[ (t + m - 1)\, g_{p+m}(t) = g_p(t+m)\, g_m(t)\, (t^p - t)^m . \] In particular, the polynomial $g_{p+m}$ is divisible by $(t + m - 1)^{m-1}$ modulo $p$. \end{corollary} \begin{proof} By Lemmas~\ref{lem:2.1} and~\ref{lem:2.3}, $J_n = (t+n-1)^n (t)_{n-1} g_n$ with $(t)_{k} = t(t+1)\cdots(t+k-1)$. Modulo $p$, with $n = p+m$, one has $t + n - 1 \equiv t + m - 1$ and $(t)_{n-1} = (t)_{m-1}\,(t+m-1)\,(t+m)(t+m+1)\cdots(t+m+p-2)$. Inserting this into Theorem~\ref{thm:3.1} and cancelling the common nonzero factors $(t+m-1)^{n}(t)_{m-1}(t+m)\cdots(t+m+p-2)$ in the domain $\F_p[t]$ gives the identity. The factor $t^p - t = \prod_{c \in \F_p}(t-c)$ contains $t + m - 1$ once, so $(t^p - t)^m/(t+m-1)$ is divisible by $(t+m-1)^{m-1}$. \end{proof} At $t \equiv 1 - n \equiv 1 - m$ the corollary gives $g_n(1-n) \equiv 0 \pmod p$ for $m \ge 2$, that is, $p \mid U_n$. For reduced squares this divisibility is \cite[Theorem~3.5]{SW12}, and for unipotent squares it follows from the remark after that theorem together with \cite[Table~1]{SW12} (Section~\ref{sec:1}); Corollary~\ref{cor:3.2} gives a different proof. At the other end, for $n = p$ one has $1 - p \equiv 1$, so $U_p = (-1)^{p-1} g_p(1-p) \equiv g_p(1) = ((p-1)!)^{p-1} \equiv 1 \pmod p$ by \eqref{eq:2.1} and Wilson's theorem; this is Drisko's theorem for unipotent squares of prime order \cite{Drisko98}. The congruence of Corollary~\ref{cor:3.2} is a statement about polynomials, not only about values, and the next section uses this to go one step further.