program saptesprezece; type stiva=array[1..9] of integer; var k,n:integer; s:stiva; as,ev:boolean; procedure init(var s:stiva; k :integer); begin s[k]:=0; end; procedure succesor(var s:stiva; var as:boolean; k:integer); begin if s[k]=2 then if (s[k]+s[k-1]) mod 2=0 then ev:=false; end; function solutie(k:integer):boolean; begin solutie:=(k=n); end; procedure tipar; var i:integer; begin for i:=1 to n do write(s[i],' '); writeln; end; begin write('n='); readln(n); k:=1; init(s,k); while k>0 do begin repeat succesor(s,as,k); if as then valid(s,ev,k); until (as and ev ) or (not as); if as then if solutie(k) then tipar else begin k:=k+1; init(s,k); end else k:=k-1; end; readln; end. end. readln; end.