Let $A = \{1, 2, 3, 4, 5, 6, 7\}$, and let $N$ be the number of functions $f$ from set $A$ to set $A$ such that $f(f(x))$ is a constant function. Find the remainder when $N$ is divided by $1000$.
Let $f(f(x))=c$. Then $f(c)=c$. Let $T$ be the set of $x\ne c$ with $f(x)=c$, $|T|=k\ge1$. Every other element must map into $T$ (its image is sent to $c$, but it is not sent to $c$ itself).
Let $A = \{1, 2, 3, 4, 5, 6\}$, and let $N$ be the number of functions $f$ from set $A$ to set $A$ such that $f(f(x))$ is a constant function. Find the remainder when $N$ is divided by $1000$.