solve square digit chains