This can be done with complicated algebra.
Think of a number from its decimal structure $X=(x_0x_1x_2x_3x_4x_5)_{(10)}$ there is 6 variables atleast needed to assert the congruence with 1000000.
Squaring X:
$x_0\ x_1\ x_2\ x_3\ x_4\ x_5*\\
x_0\ x_1\ x_2\ x_3\ x_4\ x_5=\\
x_0^2 10^0+\\
2x_0x_1 10^1+\\
(2x_0x_2+x_1^2) 10^2+\\
(2x_0x_3+2x_1x_2) 10^3+\\
(2x_0x_4+2x_1x_3+x_2^2) 10^4+\\
(2x_0x_5+2x_1x_4+2x_2x_3) 10^5+...$
More digits follow but this is what matters, to locate this number we just need to assign 1,4,0,0,0,0 to the first edges.
$x_0^2 =1 \rightarrow x_0=1\\
2x_0x_1=4 \rightarrow x_1=2\\
(2x_0x_2+x_1^2)=0 \rightarrow x_2=\{3,8\}\ \text{3 is rejected},c=2\\
(2x_0x_3+2x_1x_2+c)=0 \rightarrow x_3=3, c=4\\
(2x_0x_4+2x_1x_3+x_2^2+c)=0 \rightarrow x_4=0, c=8\\
(2x_0x_5+2x_1x_4+2x_2x_3+c)=0 \rightarrow x_5=5$
We can try now, $(503821)^2=253835600041=41mod10^6$