:- seqex(next/2).

color(R1,R2,R3,R4,R5,R6) :- 
	 0: next(R1,R2) ==> 2;
	 2: next(R2,R3) ==> 6, null ==> 3;
	 3: next(R2,R4) ==> 7, null ==> 4;
	 4: next(R2,R5) ==> 8, null ==> 5;
	 5: next(R2,R6) ==> 9, null ==> 6;	
	 6: next(R1,R3) ==> 15, null ==> 10;
	 7: null ==> 12;
	 8: next(R1,R5) ==> 15, null ==> 14;
	 9: next(R1,R6) ==> 16, null ==> 11;
	10: null ==> 12, null ==> 13;
	11: null ==> 13, null ==> 14;
	12: next(R3,R4) ==>  16; 
	13: next(R3,R6) ==>  17;
	14: next(R5,R6) ==>  17;
	15: null ==> 1;
	16: null ==> 18;
	17: null ==> 18;
	18: null ==> 1.

next(blue,red). next(blue,green). next(blue,yellow).
	 	next(red,green).  next(red,yellow). 	next(red,blue).
next(green,red). 		  next(green,yellow).	next(green,blue).
next(yellow,red). next(yellow,green).			next(yellow,blue).

?- next(R1,R2) -> color(R1,R2,R3,R4,R5,R6).

