use bigint;sub f{grep{$_<2or$_&1&&f($_/2)?print"A":$_%3&1&&f($_/3)&&print"B"}@_}f<>