Finding a unique cube root

If we have an integer(say ) which ends in either 1,3,7 or 9 then how can one find another integer having at most the same number of digits as but when cubed would end in exactly the same digit as .
E.g if a = 123
then the required number is 927 because 123 ends in 3 and 927^3 also ends in 3 .
Other examples:
a = 435621 then required number is 786941
Thanks.

If we have an integer (say ) which ends in either 1, 3, 7 or 9,
then how can one find another integer having at most the same number of digits as
but when cubed would end in exactly the same digit as .

E.g. .if a = 123, then the required number is 927
because 123 ends in 3 and 923^3 also ends in 3.. . It could be any 3-digit number (or smaller) ending in 7.

Another example: .a = 435621, then required number is 786941.. . It could be any 6-digit number (or smaller) ending in 1.