:- seqex(next/2). 

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

?- color(blue,R2,R3,R4,R5,R6). 

/* ?- color(blue,green,red,blue,red,blue), write(done), nl. */