working trinary to decimal converter