prolog easy program.. Easy \$\$

Hi,
anyone can figure this problem.

It is a 3x3 number puzzle. We start with for example,

+------+------+------+
| 1 | 2 | x |
+------+------+------+
| 4 | 5 | 3 |
+------+------+------+
| 7 | 8 | 6 |
+------+------+------+

uses 'x' to indicate where the empty position currently is in one state. we want to end up with the below shape at the final state:

+------+------+------+
| 1 | 2 | 3 |
+------+------+------+
| 4 | 5 | 6 |
+------+------+------+
| 7 | 8 | x |
+------+------+------+

we are given this code and only need the code for move:

solution(Row1,Row2,Row3,History) :-
move(Row1,Row2,Row3,NewRow1,NewRow2,NewRow3),
\+ member(state(NewRow1,NewRow2,NewRow3),History),
solution(NewRow1,NewRow2,NewRow3,[state(Row1,Row2,Row3)|History]).

The first three arguments are representations of each of the three rows in the puzzle. The fourth argument 'History' is a list of previous states that we have traveled through.

Anyways, calling
?- solution([1,2,x],[4,5,3],[7,8,6],[]).

should solve the puzzle.

This should be easy for any prolog programmer, I just don't know prolog so any takers, please reply or e-mail me at mb@ugt.ca
Thank you