A drunken man walks in a two-dimensional grid.He can walk rigth(1),down(2),left(3),up(4).After determined number of steps,for example,6 steps,he has 400 ways go back home(the number of 1(2) equal to 3(4)，assume the number of 2(3) larger tan 1(3),then just 200 ways).

```
move = {1, 2, 3, 4};
AllWays[n_ /; EvenQ[n]] := {{1, 3} & /@ Range[#1], {2, 4} & /@ Range[#2]} & @@@
   PadLeft[IntegerPartitions[n/2, {0, 2}]] // Flatten /@ # & // Permutations /@ # & 
   // Join @@ # &

```

so if 6 steps,we will get:

```
{{2, 4, 2, 4, 2, 4}, {2, 4, 2, 4, 4, 2}, << 196 >>, {4, 2, 3, 1, 3, 1}, {4, 2, 3, 3, 1, 1}}

```

we can plot arrow pictures for this.

```
rule = {1 -> {1, 0}, 2 -> {0, -1}, 3 -> {-1, 0}, 4 -> {0, 1}};
handle[list_] := With[{n = Length[list] - 1},
    If[First[Subtract @@ #] == 0, 
      # + If[#[[1, 2]] < #[[2, 2]],{{0, 0.1}, {0, -0.1}}, {{0, -0.1}, {0,0.1}}], 
      # + If[#[[1, 1]] < #[[2, 1]], {{0.1, 0}, {-0.1, 0}}, {{-0.1, 0}, {0.1, 0}}]]
    & /@ (Transpose[{list,If[First[#2 - #1 & @@ First[list]] == 0,
     {{#, 0}, {#, 0}},{{0, #}, {0, #}}] & /@ Range[-0.05 n, 0.05 n, 0.1]}] 
     // Plus @@@ # &)]
ArrowPlot[moves_] := 
    Gather[Partition[Accumulate[moves /. rule], 2, 1, 1],Sort[#1] == Sort[#2] &] 
    //handle /@ # & // Flatten[#, 1] & 
    //Graphics[{Arrowheads[Medium], Arrow[#]}, ImageSize -> {70, 70}] &

```

so ArrowPlot[{1, 1, 4, 2, 3, 2, 3, 4}] will get:

![enter image description here](https://i.stack.imgur.com/31D2j.jpg)

But there are three types of equivalence.

1.Topologically equivalence
 For example,{1, 2, 3, 4, 3, 4, 2, 1} is equal to {1, 2, 3, 4, 3, 2, 4, 1},because the images is

![enter image description here](https://i.stack.imgur.com/vCBZs.jpg)

2.Translational equivalence
 For example,{1, 4, 1, 3, 3, 2} is equal to {4, 1, 3, 3, 2, 1},because they just have diffencnce origin,the images is

![enter image description here](https://i.stack.imgur.com/wUD6b.jpg)

3.Rotate or reflect equivalence
 For example,{1, 4, 1, 3, 3, 2} is equal to {1, 2, 3, 2, 4, 4},because the images is 

![enter image description here](https://i.stack.imgur.com/xZFBX.jpg)

Obviously in 6 steps,Length[AllWays[6]] just equal to 200.It just has 7 difference ways,the images is

![enter image description here](https://i.stack.imgur.com/MQLBK.jpg)

but in 8(10) steps,Length[AllWays[8(10)]] equal to 3710(31752).and the difference ways just equal to 20+(100+),how to write a program to tally those?