Encoding & Decoding + Prime method