20 minutes to pass -brief, yuck.
#!perl -l for$n(0..pop){($_*$n+$`)=~/.$/,$_=$&for@t;$t[@t]=1}"@t"=~/[1-9]/;print$&