Perfect coding