this is the first version of ternary.pl