input, output and enumeration algo