1989 AIME Problem 14

Given a positive integer n, it can be shown that every complex number of the form r+s i, where r and s are integers, can be uniquely expressed in the base -n+i using the integers 0,1,2, \ldots, n^{2} as “digits.” That is, the equation

r+s i=a_{m}(-n+i)^{m}+a_{m-1}(-n+i)^{m-1}+\cdots+a_{1}(-n+i)+a_{0}

is true for a unique choice of non-negative integer m and digits a_{0}, a_{1}, \ldots, a_{m} chosen from the set \left\{0,1,2, \ldots, n^{2}\right\}, with a_{m} \neq 0. We then write

r+s i=\left(a_{m} a_{m-1} \ldots a_{1} a_{0}\right)_{-n+i}

to denote the base -n+i expansion of r+s i. There are only finitely many integers k+0 i that have four-digit expansions

k=\left(a_{3} a_{2} a_{1} a_{0}\right)_{-3+i} \quad a_{3} \neq 0 .

Find the sum of all such k.