:- seqex(next/2).

color(R1,R2,R3,R4,R5,R6) :- 
	 0: next(R1,R2) ==> 2, next(R3,R4) ==> 3, next(R5,R6) ==> 4;
	 2: null ==> 5, null ==> 6;
	 3: null ==> 5, null ==> 7;
	 4: null ==> 6, null ==> 7;
	 5: next(R2,R4) ==> 8,  next(R1,R3) ==> 8, next(R2,R3) ==> 11;
	 6: next(R2,R5) ==> 9,  next(R2,R6) ==> 9,
	    next(R1,R5) ==> 10, next(R1,R6) ==> 10;	
	 7: next(R3,R6) ==> 11;
	 8: null ==> 12;
	 9: null ==> 12;
	10: null ==> 13;
	11: null ==> 13;
	12: null ==> 1;
	13: 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).

