Given an amino acid string Peptide, its ideal spectrum, denoted IdealSpectrum(Peptide), is the collection of integer masses of all its prefixes and suffixes. Note that an ideal spectrum may have repeated masses; for example, IdealSpectrum(GPG) = {0, 57, 57, 154, 154, 211}. We say that an amino acid string Peptide explains a collection of integers Spectrum if IdealSpectrum(Peptide) = Spectrum.

The following pseudocode finds a peptide explaining a given spectrum.

DecodingIdealSpectrum(Spectrum)
     construct Graph(Spectrum)
     for each path Path from source to sink in Graph(Spectrum)
          Peptide ← the amino acid string spelled by the edge labels of Path
          if IdealSpectrum(Peptide) = Spectrum
                return Peptide

Assignment

Given a space-delimited list of integers, Spectrum.

Return an amino acid string with an ideal spectrum that matches Spectrum.

Example

>>> decoding_ideal_spectrum([57, 103, 160, 160])
'GC'

>>> decoding_ideal_spectrum([71, 163, 257, 326, 420, 512, 583, 583])
'AWYY'