Cuber QQ has encountered a math problem during his research of "nothing related to math", he thought the problem too boring for him, and decided to leave it to you. You might be curious about more background about why this problem appeared in his research, but to save your time, let's say "the background isn't helpful for you to solve this problem".
Given $n$, $m$, count the number of sequence $x_1, x_2, \ldots, x_n$ such that $x_1^2 + x_2^2 + \cdots + x_{n-1}^2 \equiv x_n^2 \pmod m$ and $0 \le x_i < m$ for $1 \le i \le n$. $m$ is odd in this problem.