algorithm transfer one coin matrix to another coin matrix
<p><strong>Description:</strong><br>
 There are m * n (m &lt;= 100, n &lt;=100) coins on the desktop forming a m row n column coin matrix. Every coin either face upward, or face backward, represented by 0 or 1.</p>

<p>Rules of the game are:</p>

<p>(1) every time, you are allowed to inverse one row of coins.<br>
  (2) every time, you are allowed to swap two columns.</p>

<p><strong>Object:</strong><br>
  from initial matrix -> target matrix</p>

<p><strong>Input:</strong><br>
   1. k the count of test caese<br>
   2. m n the count of rows and columns<br>
   3. the numbers of the inital matrix and the target matrix   </p>

<p><strong>Output</strong>
   the least steps from initial matrix to target matrix, if it is not possible to transfer from initial to target, output -1.</p>

<p><strong>sample intput</strong></p>

<p>2<br>
4 3<br>
1 0 1<br>
0 0 0<br>
1 1 0<br>
1 0 1   </p>

<p>1 0 1<br>
1 1 1<br>
0 1 1<br>
1 0 1   </p>

<p>4 3<br>
1 0 1<br>
0 0 0<br>
1 0 0<br>
1 1 1   </p>

<p>1 1 0<br>
1 1 1<br>
0 1 1<br>
1 0 1  </p>

<p><strong>sample output</strong></p>

<p>2  </p>

<p>-1</p>

<p>I have coded one solution: <a href="https://code.google.com/p/wxd/source/browse/trunk/prog14.cc" rel="nofollow">mysolution.cc</a>, which enumerate all posibilities and which is correct but it is too slow, could you provide a correct but fast solution.</p>

<p>Thanks.</p>
