Magic encoding