The set $Z(m,n)$ consists of all integers $N$ with $mn$ digits which have precisely $n$ ones, $n$ twos, $n$ threes, $\ldots$, $n$ $m$'s. For each integer $N\in Z(m,n)$, define $d(N)$ to be the sum of the absolute values of the differences of all pairs of consecutive digits. For example, $122313\in Z(3,2)$ with
$$d(122313)=1+0+1+2+2=6.$$
Find the average value of $d(N)$ as $N$ ranges over all possible elements of $Z(m,n)$.