parse(S,L) :- atom_chars(S,Chars), string(L, Chars, []).

string([N,NN,NNN]) --> as(N), {NN is 2*N}, bs(NN), {NNN is 3*N}, cs(NNN).

as(N) --> [a], as(M), {N is M+1}.
as(0) --> [].

bs(N) --> [b], bs(M), {N is M+1}.
bs(0) --> [].

cs(N) --> [c], cs(M), {N is M+1}.
cs(0) --> [].
