For a positive integer n, let f(n) be the sum of the squares of the digits (in base 10) of n, e.g.
Find the last nine digits of the sum of all n, 0<n<1020, such that f(n) is a perfect square.