2022 SSMO Relay Round 3 Problems/Problem 1

Problem

Let $f:\mathbb Z\rightarrow\mathbb Z$ be a function such that $f(0)=0$ and $f\left(|x^2-4|\right)=0$ if $f(x)=0$. Moreover, $|f(x+1)-f(x)|=1$ for all $x\in \mathbb Z$. Let $N$ be the number of possible sequences $\{f(1),f(2),\dots,f(21)\}$. Find the remainder when $N$ is divided by 1000.

Solution