Solve p50 (huffman encoding)