Page 2 of 2
Posted: Fri Dec 16, 2005 3:34 pm
alzika wrote:The square A you have listed above, is there only 2 rotations for it, or 4? Meaning if it was the lower right corner square, should I count it twice for two different possible ways to arrive at the goal (if it has 4 rotations)?
It has exactly 2 rotations:

Code: Select all

``````          *
***       *
*
``````

Posted: Sat Jul 01, 2006 10:15 pm
the LA-Z-BOy wrote:btw. the second input given by titid_gede isn't valid i think...

Code: Select all

``````1 1
+---+
| * |
| * |
| * |
+---+
``````
because as the problem states... all the patterns should be in the `initial' form...
True, but this is valid:

Code: Select all

``````input:
1
1 1
+---+
|   |
|***|
|   |
+---+

output:
Number of solutions: 2
``````

Posted: Fri Jul 20, 2007 4:54 pm
what's the bug of my code

Code: Select all

``````#include <stdio.h>

#define N 0
#define S 1
#define E 2
#define W 3
#define NONE 4
#define VISIT 5

int a[66][66], t, m, n, i, j, c;
char s[1000];

void fill(int i, int j, int dir)
{
if (i >= 0 && j >= 0 && i < m && j < n && a[i][j] != VISIT && a[i][j])
{
printf("%d %d\n", i, j);
int tmp = a[i][j];
if (i == m-1 && j == n-1 && dir != NONE)
{
c++;
return;
}
if (dir == N)
{
puts("N");
if (a[i][j] == 1)
{
a[i][j] = VISIT;
fill(i+1, j, N);
} else
if (a[i][j] == 2)
{
a[i][j] = VISIT;
fill(i, j+1, W);
fill(i, j-1, E);
}
} else
if (dir == S)
{
puts("S");
if (a[i][j] == 1)
{
a[i][j] = VISIT;
fill(i-1, j, S);
} else
if (a[i][j] == 2)
{
a[i][j] = VISIT;
fill(i, j+1, W);
fill(i, j-1, E);
}
} else
if (dir == E)
{
puts("E");
if (a[i][j] == 1)
{
a[i][j] = VISIT;
fill(i, j-1, E);
} else
if (a[i][j] == 2)
{
a[i][j] = VISIT;
fill(i-1, j, S);
fill(i+1, j, N);
}
} else
if (dir == W)
{
puts("W");
if (a[i][j] == 1)
{
a[i][j] = VISIT;
fill(i, j-1, W);
} else
if (a[i][j] == 2)
{
a[i][j] = VISIT;
fill(i-1, j, S);
fill(i+1, j, N);
}
} else
if (dir == NONE)
{
if (a[i][j] == 1 || a[i][j] == 2)
{
a[i][j] = VISIT;
fill(i, j+1, W);
fill(i+1, j, N);
}
}
a[i][j] = tmp;
}
}

int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%d%d", &m, &n);
getchar();
c = 0;
for (i = 0; i < m; i++)
{
gets(s);
gets(s);
gets(s);
for (j = 0; j < n; j++)
if (s[4*j+2] == ' ') a[i][j] = 0; else
if (s[4*j+3] == '*') a[i][j] = 1; else
a[i][j] = 2;
gets(s);
}
gets(s);
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
printf("%d ", a[i][j]);
puts("");
}
fill(0, 0, NONE);
printf("Number of solutions: %d\n", c);
}
}
``````

### Re: 10582 - ASCII Labyrinth

Posted: Fri Mar 25, 2016 5:16 pm
Some I/O

In:

Code: Select all

``````125

5 7
+---+---+---+---+---+---+---+
+   +   + * +   +   +   +   +
+** +** + * +   + **+   + **+
+ * + * + * +   + * +   + * +
+---+---+---+---+---+---+---+
+   +   +   + * +   + * + * +
+   +   +** +** +** +** +** +
+   +   + * +   + * +   +   +
+---+---+---+---+---+---+---+
+   + * +   +   +   +   +   +
+** +** + **+***+ **+ **+***+
+ * +   + * +   + * + * +   +
+---+---+---+---+---+---+---+
+ * +   +   +   +   + * +   +
+** + **+ **+***+   +** +***+
+   + * + * +   +   +   +   +
+---+---+---+---+---+---+---+
+ * +   + * +   + * +   +   +
+ **+   + **+ **+ **+***+** +
+   +   +   + * +   +   + * +
+---+---+---+---+---+---+---+

5 7
+---+---+---+---+---+---+---+
+   + * + * +   +   +   +   +
+** +** + * + **+   +***+***+
+ * +   + * + * +   +   +   +
+---+---+---+---+---+---+---+
+ * + * +   +   +   +   +   +
+ * + **+   +   +***+***+ **+
+ * +   +   +   +   +   + * +
+---+---+---+---+---+---+---+
+ * +   + * + * +   + * +   +
+ **+***+ **+ **+** + * +   +
+   +   +   +   + * + * +   +
+---+---+---+---+---+---+---+
+   +   + * +   +   + * + * +
+   +** + * +   +   + * +** +
+   + * + * +   +   + * +   +
+---+---+---+---+---+---+---+
+ * + * + * + * + * +   +   +
+ * + **+** + **+ **+***+** +
+ * +   +   +   +   +   + * +
+---+---+---+---+---+---+---+

3 4
+---+---+---+---+
+ * + * +   +   +
+ **+ **+   +   +
+   +   +   +   +
+---+---+---+---+
+   + * +   +   +
+** + * + **+   +
+ * + * + * +   +
+---+---+---+---+
+   +   + * +   +
+ **+ **+ * +** +
+ * + * + * + * +
+---+---+---+---+

4 4
+---+---+---+---+
+   +   + * +   +
+** +** +** + **+
+ * + * +   + * +
+---+---+---+---+
+   +   + * +   +
+***+** + * +** +
+   + * + * + * +
+---+---+---+---+
+   +   + * + * +
+***+ **+** + **+
+   + * +   +   +
+---+---+---+---+
+   +   +   + * +
+***+   +***+ **+
+   +   +   +   +
+---+---+---+---+

8 6
+---+---+---+---+---+---+
+ * +   +   + * + * + * +
+ **+***+ **+** + **+** +
+   +   + * +   +   +   +
+---+---+---+---+---+---+
+ * + * +   +   +   + * +
+** + **+   +   +** +** +
+   +   +   +   + * +   +
+---+---+---+---+---+---+
+ * +   +   +   + * + * +
+** + **+ **+   + * +** +
+   + * + * +   + * +   +
+---+---+---+---+---+---+
+ * +   + * +   +   + * +
+** +***+ **+***+** + **+
+   +   +   +   + * +   +
+---+---+---+---+---+---+
+   +   +   + * +   +   +
+***+***+   + **+***+ **+
+   +   +   +   +   + * +
+---+---+---+---+---+---+
+ * +   +   + * + * + * +
+ * + **+** + **+ * + * +
+ * + * + * +   + * + * +
+---+---+---+---+---+---+
+   + * +   +   +   + * +
+***+ **+ **+** +   +** +
+   +   + * + * +   +   +
+---+---+---+---+---+---+
+   + * +   + * + * +   +
+ **+ **+** + **+ **+** +
+ * +   + * +   +   + * +
+---+---+---+---+---+---+

4 2
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+
+ * + * +
+ **+** +
+   +   +
+---+---+
+   +   +
+   + **+
+   + * +
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+

7 7
+---+---+---+---+---+---+---+
+   + * +   +   +   +   + * +
+** + * + **+   +** +   + **+
+ * + * + * +   + * +   +   +
+---+---+---+---+---+---+---+
+   +   +   +   +   +   +   +
+   +   +** + **+***+   +***+
+   +   + * + * +   +   +   +
+---+---+---+---+---+---+---+
+   + * +   +   +   +   +   +
+   + * +   + **+ **+***+   +
+   + * +   + * + * +   +   +
+---+---+---+---+---+---+---+
+ * +   +   +   +   +   +   +
+ **+   +   + **+** +** +** +
+   +   +   + * + * + * + * +
+---+---+---+---+---+---+---+
+   +   + * + * +   +   +   +
+   +   + * + * +** +** +***+
+   +   + * + * + * + * +   +
+---+---+---+---+---+---+---+
+   + * + * +   +   +   +   +
+** + **+** +   +***+***+   +
+ * +   +   +   +   +   +   +
+---+---+---+---+---+---+---+
+   +   +   +   + * +   + * +
+***+   +   +** + * + **+ **+
+   +   +   + * + * + * +   +
+---+---+---+---+---+---+---+

6 5
+---+---+---+---+---+
+ * + * +   + * +   +
+ **+** +   + **+   +
+   +   +   +   +   +
+---+---+---+---+---+
+   +   +   +   +   +
+ **+   +** + **+   +
+ * +   + * + * +   +
+---+---+---+---+---+
+ * +   +   +   +   +
+** +   + **+ **+** +
+   +   + * + * + * +
+---+---+---+---+---+
+   + * +   + * + * +
+   +** +   + **+** +
+   +   +   +   +   +
+---+---+---+---+---+
+   +   +   + * + * +
+ **+ **+ **+** + * +
+ * + * + * +   + * +
+---+---+---+---+---+
+ * + * +   + * +   +
+ * +** +***+ * +** +
+ * +   +   + * + * +
+---+---+---+---+---+

3 7
+---+---+---+---+---+---+---+
+   + * +   + * + * + * +   +
+** + **+   + **+ * + * + **+
+ * +   +   +   + * + * + * +
+---+---+---+---+---+---+---+
+   +   +   + * +   + * +   +
+   +***+ **+ * +***+ **+** +
+   +   + * + * +   +   + * +
+---+---+---+---+---+---+---+
+ * +   +   +   +   +   + * +
+ * + **+***+ **+***+** + **+
+ * + * +   + * +   + * +   +
+---+---+---+---+---+---+---+

1 2
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+

8 5
+---+---+---+---+---+
+   +   +   +   + * +
+** +***+** +   + **+
+ * +   + * +   +   +
+---+---+---+---+---+
+ * +   +   +   + * +
+ * +   +***+   +** +
+ * +   +   +   +   +
+---+---+---+---+---+
+ * + * +   +   +   +
+** + * +** +   + **+
+   + * + * +   + * +
+---+---+---+---+---+
+   + * +   + * + * +
+***+** +** + * +** +
+   +   + * + * +   +
+---+---+---+---+---+
+ * + * +   + * +   +
+ * + **+   +** +***+
+ * +   +   +   +   +
+---+---+---+---+---+
+ * + * +   +   +   +
+** + **+** +   +***+
+   +   + * +   +   +
+---+---+---+---+---+
+   +   +   +   +   +
+** +** +** +** +** +
+ * + * + * + * + * +
+---+---+---+---+---+
+   +   + * +   +   +
+** +***+ * +** +** +
+ * +   + * + * + * +
+---+---+---+---+---+

6 4
+---+---+---+---+
+   +   + * + * +
+** + **+ **+ **+
+ * + * +   +   +
+---+---+---+---+
+   +   +   + * +
+***+** +** + **+
+   + * + * +   +
+---+---+---+---+
+ * + * +   + * +
+ **+ * +** +** +
+   + * + * +   +
+---+---+---+---+
+   +   +   +   +
+** + **+***+** +
+ * + * +   + * +
+---+---+---+---+
+ * +   +   +   +
+ **+***+ **+***+
+   +   + * +   +
+---+---+---+---+
+   +   +   + * +
+***+ **+ **+ **+
+   + * + * +   +
+---+---+---+---+

2 7
+---+---+---+---+---+---+---+
+   + * + * +   + * +   + * +
+** + * + * + **+** +** +** +
+ * + * + * + * +   + * +   +
+---+---+---+---+---+---+---+
+ * +   + * + * +   + * + * +
+ **+   +** + * + **+** + **+
+   +   +   + * + * +   +   +
+---+---+---+---+---+---+---+

2 8
+---+---+---+---+---+---+---+---+
+ * +   + * + * + * + * +   + * +
+ **+ **+ **+ **+ **+ **+***+ **+
+   + * +   +   +   +   +   +   +
+---+---+---+---+---+---+---+---+
+ * +   +   +   +   +   + * +   +
+ * +** + **+ **+ **+   + * +** +
+ * + * + * + * + * +   + * + * +
+---+---+---+---+---+---+---+---+

4 7
+---+---+---+---+---+---+---+
+ * +   + * + * + * +   + * +
+ **+** + * + * + **+** + **+
+   + * + * + * +   + * +   +
+---+---+---+---+---+---+---+
+ * + * + * + * + * +   +   +
+ **+** + * + **+** + **+ **+
+   +   + * +   +   + * + * +
+---+---+---+---+---+---+---+
+   +   + * +   +   + * + * +
+***+** +** + **+   + * + * +
+   + * +   + * +   + * + * +
+---+---+---+---+---+---+---+
+ * +   +   +   + * + * +   +
+ * +   +** +***+** +** +** +
+ * +   + * +   +   +   + * +
+---+---+---+---+---+---+---+

5 5
+---+---+---+---+---+
+ * +   + * +   +   +
+ **+   + * +** + **+
+   +   + * + * + * +
+---+---+---+---+---+
+   + * + * +   + * +
+***+ **+ **+ **+ * +
+   +   +   + * + * +
+---+---+---+---+---+
+   + * +   + * + * +
+***+** + **+** + **+
+   +   + * +   +   +
+---+---+---+---+---+
+   + * +   +   +   +
+***+ * +   +***+ **+
+   + * +   +   + * +
+---+---+---+---+---+
+ * +   +   +   +   +
+ * +   +***+***+** +
+ * +   +   +   + * +
+---+---+---+---+---+

4 8
+---+---+---+---+---+---+---+---+
+   + * +   +   +   + * +   +   +
+** + **+** +   +   +** +***+***+
+ * +   + * +   +   +   +   +   +
+---+---+---+---+---+---+---+---+
+ * + * + * + * +   + * +   +   +
+ **+** + **+ **+***+** +   +** +
+   +   +   +   +   +   +   + * +
+---+---+---+---+---+---+---+---+
+   + * + * +   + * +   + * +   +
+** +** +** +** + **+   + **+** +
+ * +   +   + * +   +   +   + * +
+---+---+---+---+---+---+---+---+
+   +   +   + * +   + * + * + * +
+** +** +***+** +***+** + **+ **+
+ * + * +   +   +   +   +   +   +
+---+---+---+---+---+---+---+---+

7 7
+---+---+---+---+---+---+---+
+   +   +   +   +   +   +   +
+** +** +***+** +** +***+** +
+ * + * +   + * + * +   + * +
+---+---+---+---+---+---+---+
+   +   + * +   +   +   + * +
+ **+   + * +** + **+ **+** +
+ * +   + * + * + * + * +   +
+---+---+---+---+---+---+---+
+ * +   + * +   +   +   +   +
+ **+ **+ **+   +** +***+** +
+   + * +   +   + * +   + * +
+---+---+---+---+---+---+---+
+   +   + * + * +   +   +   +
+ **+   + **+ **+***+** +** +
+ * +   +   +   +   + * + * +
+---+---+---+---+---+---+---+
+   +   +   + * +   + * + * +
+** +** +***+ **+   +** + * +
+ * + * +   +   +   +   + * +
+---+---+---+---+---+---+---+
+ * +   + * + * + * + * +   +
+ **+** + **+** + * +** + **+
+   + * +   +   + * +   + * +
+---+---+---+---+---+---+---+
+ * + * +   +   + * +   + * +
+ * + **+ **+   + **+** + **+
+ * +   + * +   +   + * +   +
+---+---+---+---+---+---+---+

6 3
+---+---+---+
+   + * +   +
+** + * +***+
+ * + * +   +
+---+---+---+
+   +   + * +
+ **+** + * +
+ * + * + * +
+---+---+---+
+ * + * + * +
+ * + **+ **+
+ * +   +   +
+---+---+---+
+ * +   +   +
+ * +   +** +
+ * +   + * +
+---+---+---+
+   + * + * +
+   + **+** +
+   +   +   +
+---+---+---+
+   + * + * +
+   +** + **+
+   +   +   +
+---+---+---+

8 5
+---+---+---+---+---+
+ * +   + * +   + * +
+ **+ **+ * +** + * +
+   + * + * + * + * +
+---+---+---+---+---+
+   + * + * + * +   +
+   + **+** +** +** +
+   +   +   +   + * +
+---+---+---+---+---+
+ * + * + * +   +   +
+ **+ **+ **+ **+** +
+   +   +   + * + * +
+---+---+---+---+---+
+   +   +   + * +   +
+** +** +** +** +** +
+ * + * + * +   + * +
+---+---+---+---+---+
+   +   +   + * +   +
+ **+***+ **+ * +   +
+ * +   + * + * +   +
+---+---+---+---+---+
+   +   + * + * + * +
+***+***+** + * + * +
+   +   +   + * + * +
+---+---+---+---+---+
+ * + * +   + * +   +
+** +** +***+ **+***+
+   +   +   +   +   +
+---+---+---+---+---+
+   +   +   +   +   +
+   +***+***+** +** +
+   +   +   + * + * +
+---+---+---+---+---+

5 7
+---+---+---+---+---+---+---+
+   +   +   +   + * +   + * +
+** + **+   + **+** +   + **+
+ * + * +   + * +   +   +   +
+---+---+---+---+---+---+---+
+ * +   +   +   +   + * + * +
+ **+ **+ **+ **+***+ **+** +
+   + * + * + * +   +   +   +
+---+---+---+---+---+---+---+
+ * + * +   + * +   +   + * +
+ * + **+ **+** +   +** + * +
+ * +   + * +   +   + * + * +
+---+---+---+---+---+---+---+
+ * +   + * +   + * +   +   +
+** +***+ * + **+ * + **+   +
+   +   + * + * + * + * +   +
+---+---+---+---+---+---+---+
+   +   + * +   + * + * + * +
+   +***+ **+***+** +** + **+
+   +   +   +   +   +   +   +
+---+---+---+---+---+---+---+

7 3
+---+---+---+
+ * +   + * +
+ **+***+ **+
+   +   +   +
+---+---+---+
+   + * + * +
+ **+** +** +
+ * +   +   +
+---+---+---+
+ * +   + * +
+ **+** + **+
+   + * +   +
+---+---+---+
+   +   + * +
+***+   + * +
+   +   + * +
+---+---+---+
+ * +   +   +
+ * +***+ **+
+ * +   + * +
+---+---+---+
+ * + * +   +
+** +** +** +
+   +   + * +
+---+---+---+
+ * + * +   +
+ **+** +** +
+   +   + * +
+---+---+---+

4 6
+---+---+---+---+---+---+
+ * +   + * +   +   +   +
+ **+** +** +** +***+   +
+   + * +   + * +   +   +
+---+---+---+---+---+---+
+   +   +   + * +   +   +
+***+   +** + * +** +** +
+   +   + * + * + * + * +
+---+---+---+---+---+---+
+   + * +   +   + * +   +
+   + **+** +***+ **+***+
+   +   + * +   +   +   +
+---+---+---+---+---+---+
+   + * +   + * +   +   +
+***+** + **+** +***+** +
+   +   + * +   +   + * +
+---+---+---+---+---+---+

7 6
+---+---+---+---+---+---+
+ * +   + * + * +   + * +
+ **+   +** + * +***+ **+
+   +   +   + * +   +   +
+---+---+---+---+---+---+
+ * +   + * + * +   +   +
+ **+ **+ * + * +   +** +
+   + * + * + * +   + * +
+---+---+---+---+---+---+
+   +   + * +   + * +   +
+***+** + * +   + **+ **+
+   + * + * +   +   + * +
+---+---+---+---+---+---+
+ * +   + * + * + * + * +
+** +** + * +** + **+ **+
+   + * + * +   +   +   +
+---+---+---+---+---+---+
+   +   +   + * + * +   +
+   +***+ **+ **+ * +   +
+   +   + * +   + * +   +
+---+---+---+---+---+---+
+ * +   + * + * + * +   +
+ * +** + * +** +** +   +
+ * + * + * +   +   +   +
+---+---+---+---+---+---+
+   + * + * +   +   +   +
+ **+** + * + **+   +** +
+ * +   + * + * +   + * +
+---+---+---+---+---+---+

3 5
+---+---+---+---+---+
+ * +   +   +   +   +
+ **+ **+***+ **+** +
+   + * +   + * + * +
+---+---+---+---+---+
+ * + * +   +   + * +
+** + * +***+** + * +
+   + * +   + * + * +
+---+---+---+---+---+
+ * +   +   +   + * +
+ **+   + **+   + **+
+   +   + * +   +   +
+---+---+---+---+---+

4 5
+---+---+---+---+---+
+ * +   + * +   +   +
+ **+ **+** +** +** +
+   + * +   + * + * +
+---+---+---+---+---+
+   +   +   + * + * +
+** +   + **+ **+** +
+ * +   + * +   +   +
+---+---+---+---+---+
+   + * +   +   + * +
+***+ * +** +   + * +
+   + * + * +   + * +
+---+---+---+---+---+
+ * +   +   +   + * +
+ * +   +***+   + **+
+ * +   +   +   +   +
+---+---+---+---+---+

8 5
+---+---+---+---+---+
+   +   + * +   + * +
+** +   +** +** +** +
+ * +   +   + * +   +
+---+---+---+---+---+
+   +   +   +   + * +
+   +** + **+   + * +
+   + * + * +   + * +
+---+---+---+---+---+
+   +   +   + * + * +
+***+** + **+** + **+
+   + * + * +   +   +
+---+---+---+---+---+
+ * +   +   + * + * +
+ **+** + **+ * +** +
+   + * + * + * +   +
+---+---+---+---+---+
+   +   +   + * +   +
+***+ **+** + * + **+
+   + * + * + * + * +
+---+---+---+---+---+
+   + * +   + * + * +
+***+** + **+ * +** +
+   +   + * + * +   +
+---+---+---+---+---+
+   +   + * +   +   +
+***+** +** +***+***+
+   + * +   +   +   +
+---+---+---+---+---+
+   +   + * + * + * +
+ **+***+** + **+ **+
+ * +   +   +   +   +
+---+---+---+---+---+

1 6
+---+---+---+---+---+---+
+ * +   + * + * + * +   +
+ **+** +** +** +** +** +
+   + * +   +   +   + * +
+---+---+---+---+---+---+

6 6
+---+---+---+---+---+---+
+ * + * +   + * + * +   +
+ **+ **+***+ **+ * + **+
+   +   +   +   + * + * +
+---+---+---+---+---+---+
+ * + * +   +   +   +   +
+ **+ **+   +***+***+***+
+   +   +   +   +   +   +
+---+---+---+---+---+---+
+   + * +   +   +   + * +
+ **+** +   + **+***+** +
+ * +   +   + * +   +   +
+---+---+---+---+---+---+
+   + * +   + * +   +   +
+ **+ * +** +** +***+***+
+ * + * + * +   +   +   +
+---+---+---+---+---+---+
+ * +   + * +   +   +   +
+ **+ **+ **+ **+***+ **+
+   + * +   + * +   + * +
+---+---+---+---+---+---+
+ * + * +   + * + * +   +
+ * + **+   + **+ * +** +
+ * +   +   +   + * + * +
+---+---+---+---+---+---+

6 6
+---+---+---+---+---+---+
+   +   +   +   + * + * +
+** +   +***+   + * + * +
+ * +   +   +   + * + * +
+---+---+---+---+---+---+
+ * +   + * + * + * + * +
+ * +** + * + * +** +** +
+ * + * + * + * +   +   +
+---+---+---+---+---+---+
+ * +   +   + * +   +   +
+ * +   + **+** +***+***+
+ * +   + * +   +   +   +
+---+---+---+---+---+---+
+ * + * + * +   + * +   +
+** + **+** + **+** + **+
+   +   +   + * +   + * +
+---+---+---+---+---+---+
+   + * +   +   +   +   +
+ **+ **+   +** +   +***+
+ * +   +   + * +   +   +
+---+---+---+---+---+---+
+   + * +   + * + * + * +
+ **+** + **+ * + * + **+
+ * +   + * + * + * +   +
+---+---+---+---+---+---+

7 2
+---+---+
+ * + * +
+ **+ * +
+   + * +
+---+---+
+ * + * +
+** + * +
+   + * +
+---+---+
+   +   +
+   + **+
+   + * +
+---+---+
+   + * +
+** +** +
+ * +   +
+---+---+
+ * + * +
+ **+ **+
+   +   +
+---+---+
+   +   +
+***+***+
+   +   +
+---+---+
+   +   +
+***+** +
+   + * +
+---+---+

5 4
+---+---+---+---+
+ * + * +   +   +
+ **+ **+***+   +
+   +   +   +   +
+---+---+---+---+
+ * +   + * +   +
+ **+   + **+ **+
+   +   +   + * +
+---+---+---+---+
+ * + * +   + * +
+ **+ * +***+ * +
+   + * +   + * +
+---+---+---+---+
+ * +   +   +   +
+ * +***+ **+   +
+ * +   + * +   +
+---+---+---+---+
+ * +   +   +   +
+ **+***+   +** +
+   +   +   + * +
+---+---+---+---+

5 4
+---+---+---+---+
+   +   +   +   +
+** +** +***+ **+
+ * + * +   + * +
+---+---+---+---+
+ * + * + * +   +
+** + **+ * + **+
+   +   + * + * +
+---+---+---+---+
+   +   + * + * +
+***+** + * +** +
+   + * + * +   +
+---+---+---+---+
+ * +   +   + * +
+** +***+ **+** +
+   +   + * +   +
+---+---+---+---+
+   +   + * + * +
+ **+***+** + **+
+ * +   +   +   +
+---+---+---+---+

5 4
+---+---+---+---+
+   + * + * +   +
+** +** + * + **+
+ * +   + * + * +
+---+---+---+---+
+   +   + * +   +
+** +   + * +***+
+ * +   + * +   +
+---+---+---+---+
+   + * +   +   +
+   +** +   +** +
+   +   +   + * +
+---+---+---+---+
+ * +   +   +   +
+ * +** +** +***+
+ * + * + * +   +
+---+---+---+---+
+   +   +   +   +
+   +   +** +** +
+   +   + * + * +
+---+---+---+---+

1 3
+---+---+---+
+   +   + * +
+** +   + **+
+ * +   +   +
+---+---+---+

6 2
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+
+   +   +
+ **+ **+
+ * + * +
+---+---+
+   +   +
+***+   +
+   +   +
+---+---+
+ * +   +
+ * + **+
+ * + * +
+---+---+
+ * +   +
+ **+   +
+   +   +
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+

3 7
+---+---+---+---+---+---+---+
+ * +   +   + * +   + * + * +
+ **+***+** + **+   + * + **+
+   +   + * +   +   + * +   +
+---+---+---+---+---+---+---+
+ * +   +   + * +   +   + * +
+ * +***+** + * +** +   +** +
+ * +   + * + * + * +   +   +
+---+---+---+---+---+---+---+
+   +   + * + * + * +   +   +
+** +   +** + **+** +** +** +
+ * +   +   +   +   + * + * +
+---+---+---+---+---+---+---+

5 5
+---+---+---+---+---+
+   + * +   + * +   +
+** + **+** + * + **+
+ * +   + * + * + * +
+---+---+---+---+---+
+ * +   + * +   +   +
+ * +** +** +   +***+
+ * + * +   +   +   +
+---+---+---+---+---+
+ * +   + * + * +   +
+ **+ **+ **+** +   +
+   + * +   +   +   +
+---+---+---+---+---+
+   + * +   + * +   +
+   + **+ **+** +** +
+   +   + * +   + * +
+---+---+---+---+---+
+   +   +   + * + * +
+   +   +   + * + **+
+   +   +   + * +   +
+---+---+---+---+---+

1 7
+---+---+---+---+---+---+---+
+   +   +   + * +   +   +   +
+** + **+** + **+***+** +** +
+ * + * + * +   +   + * + * +
+---+---+---+---+---+---+---+

4 8
+---+---+---+---+---+---+---+---+
+   + * + * + * + * + * + * +   +
+** + **+ **+ **+ **+** + * +***+
+ * +   +   +   +   +   + * +   +
+---+---+---+---+---+---+---+---+
+   + * +   + * + * +   +   +   +
+   +** +   +** + **+***+***+   +
+   +   +   +   +   +   +   +   +
+---+---+---+---+---+---+---+---+
+ * +   + * +   + * +   +   +   +
+ * +   + **+***+ **+***+***+** +
+ * +   +   +   +   +   +   + * +
+---+---+---+---+---+---+---+---+
+   +   +   + * +   +   + * + * +
+***+   + **+** +** +** +** + **+
+   +   + * +   + * + * +   +   +
+---+---+---+---+---+---+---+---+

6 8
+---+---+---+---+---+---+---+---+
+ * +   +   +   +   + * +   + * +
+ **+   +** + **+** + * +***+ **+
+   +   + * + * + * + * +   +   +
+---+---+---+---+---+---+---+---+
+ * +   +   + * +   + * +   +   +
+** +   +***+ **+***+ * +** +** +
+   +   +   +   +   + * + * + * +
+---+---+---+---+---+---+---+---+
+   + * +   +   + * +   + * + * +
+   + **+   +***+ **+ **+** +** +
+   +   +   +   +   + * +   +   +
+---+---+---+---+---+---+---+---+
+ * + * + * + * + * +   +   +   +
+ * + * + * +** + **+** + **+***+
+ * + * + * +   +   + * + * +   +
+---+---+---+---+---+---+---+---+
+   + * +   + * +   +   + * + * +
+   + **+   + **+   +***+** +** +
+   +   +   +   +   +   +   +   +
+---+---+---+---+---+---+---+---+
+ * +   + * +   + * + * + * + * +
+ **+***+ **+** + * + **+ **+ **+
+   +   +   + * + * +   +   +   +
+---+---+---+---+---+---+---+---+

1 4
+---+---+---+---+
+ * + * + * + * +
+ **+ * +** + **+
+   + * +   +   +
+---+---+---+---+

2 8
+---+---+---+---+---+---+---+---+
+   +   + * +   + * +   +   + * +
+** + **+ * +***+** +** +***+ * +
+ * + * + * +   +   + * +   + * +
+---+---+---+---+---+---+---+---+
+ * +   + * +   + * +   +   +   +
+ **+ **+** +** +** +***+** +** +
+   + * +   + * +   +   + * + * +
+---+---+---+---+---+---+---+---+

7 3
+---+---+---+
+   + * +   +
+** + **+ **+
+ * +   + * +
+---+---+---+
+   + * +   +
+   + * +** +
+   + * + * +
+---+---+---+
+   +   + * +
+ **+   + **+
+ * +   +   +
+---+---+---+
+   + * +   +
+ **+ * +***+
+ * + * +   +
+---+---+---+
+   + * + * +
+ **+ * +** +
+ * + * +   +
+---+---+---+
+   + * +   +
+***+ * + **+
+   + * + * +
+---+---+---+
+   + * +   +
+***+ **+** +
+   +   + * +
+---+---+---+

3 1
+---+
+ * +
+ **+
+   +
+---+
+   +
+   +
+   +
+---+
+ * +
+ **+
+   +
+---+

1 3
+---+---+---+
+ * +   +   +
+ **+   +** +
+   +   + * +
+---+---+---+

3 2
+---+---+
+ * +   +
+ **+ **+
+   + * +
+---+---+
+   +   +
+** +***+
+ * +   +
+---+---+
+   +   +
+   +** +
+   + * +
+---+---+

6 5
+---+---+---+---+---+
+ * + * +   + * +   +
+ **+ * +** +** +   +
+   + * + * +   +   +
+---+---+---+---+---+
+   +   +   + * + * +
+***+ **+   + **+** +
+   + * +   +   +   +
+---+---+---+---+---+
+ * +   + * +   +   +
+ **+ **+ * +** +** +
+   + * + * + * + * +
+---+---+---+---+---+
+   +   + * +   +   +
+** +***+** +** +***+
+ * +   +   + * +   +
+---+---+---+---+---+
+   +   + * + * + * +
+** + **+ * + **+** +
+ * + * + * +   +   +
+---+---+---+---+---+
+ * +   +   + * +   +
+ * +   +   + **+** +
+ * +   +   +   + * +
+---+---+---+---+---+

6 2
+---+---+
+ * + * +
+ **+ **+
+   +   +
+---+---+
+ * + * +
+ **+ * +
+   + * +
+---+---+
+ * +   +
+ **+ **+
+   + * +
+---+---+
+   + * +
+***+ **+
+   +   +
+---+---+
+ * + * +
+ **+ **+
+   +   +
+---+---+
+ * + * +
+ * + **+
+ * +   +
+---+---+

3 2
+---+---+
+   + * +
+** +** +
+ * +   +
+---+---+
+ * + * +
+ **+ **+
+   +   +
+---+---+
+ * + * +
+** + **+
+   +   +
+---+---+

6 2
+---+---+
+   +   +
+** +   +
+ * +   +
+---+---+
+ * + * +
+** +** +
+   +   +
+---+---+
+   +   +
+***+***+
+   +   +
+---+---+
+   +   +
+***+ **+
+   + * +
+---+---+
+ * + * +
+ * + * +
+ * + * +
+---+---+
+ * +   +
+ **+** +
+   + * +
+---+---+

2 8
+---+---+---+---+---+---+---+---+
+ * +   + * +   +   + * + * +   +
+ **+***+** +** + **+ * + * +***+
+   +   +   + * + * + * + * +   +
+---+---+---+---+---+---+---+---+
+   +   + * + * +   +   +   +   +
+   +   + **+ **+** +   +   +** +
+   +   +   +   + * +   +   + * +
+---+---+---+---+---+---+---+---+

3 6
+---+---+---+---+---+---+
+ * +   +   +   +   + * +
+ **+***+***+   +   + **+
+   +   +   +   +   +   +
+---+---+---+---+---+---+
+ * + * + * +   + * + * +
+ **+** + * +   + **+** +
+   +   + * +   +   +   +
+---+---+---+---+---+---+
+   + * +   +   + * + * +
+   + **+***+ **+** + **+
+   +   +   + * +   +   +
+---+---+---+---+---+---+

8 5
+---+---+---+---+---+
+ * +   +   +   +   +
+ **+***+** +** + **+
+   +   + * + * + * +
+---+---+---+---+---+
+ * + * +   + * +   +
+ * +** +   +** +***+
+ * +   +   +   +   +
+---+---+---+---+---+
+   +   + * +   +   +
+   +***+ **+   + **+
+   +   +   +   + * +
+---+---+---+---+---+
+   + * + * +   +   +
+** + **+** +***+***+
+ * +   +   +   +   +
+---+---+---+---+---+
+ * +   +   +   + * +
+ **+   +***+   + * +
+   +   +   +   + * +
+---+---+---+---+---+
+   +   +   + * +   +
+** +***+   + * +** +
+ * +   +   + * + * +
+---+---+---+---+---+
+   + * + * +   +   +
+***+ **+** + **+** +
+   +   +   + * + * +
+---+---+---+---+---+
+   + * +   +   + * +
+***+** +***+** + **+
+   +   +   + * +   +
+---+---+---+---+---+

2 7
+---+---+---+---+---+---+---+
+   +   + * +   +   + * + * +
+** +***+ **+   +***+ **+** +
+ * +   +   +   +   +   +   +
+---+---+---+---+---+---+---+
+ * + * +   + * +   + * +   +
+ * + * +   +** +   + * +** +
+ * + * +   +   +   + * + * +
+---+---+---+---+---+---+---+

4 7
+---+---+---+---+---+---+---+
+   +   +   + * + * +   +   +
+** +** + **+ **+** +   +** +
+ * + * + * +   +   +   + * +
+---+---+---+---+---+---+---+
+   + * + * + * +   + * +   +
+***+ **+** + * +   + * +   +
+   +   +   + * +   + * +   +
+---+---+---+---+---+---+---+
+   + * + * +   +   +   +   +
+** + * +** +***+***+***+ **+
+ * + * +   +   +   +   + * +
+---+---+---+---+---+---+---+
+ * + * + * +   +   +   + * +
+ * + **+ * +   + **+   + **+
+ * +   + * +   + * +   +   +
+---+---+---+---+---+---+---+

4 8
+---+---+---+---+---+---+---+---+
+   +   +   +   +   +   + * +   +
+** + **+ **+***+***+***+ * +   +
+ * + * + * +   +   +   + * +   +
+---+---+---+---+---+---+---+---+
+   + * + * + * +   + * +   + * +
+** +** + * + * +   +** +   + * +
+ * +   + * + * +   +   +   + * +
+---+---+---+---+---+---+---+---+
+   + * +   +   +   +   + * + * +
+   + * + **+ **+ **+** + * + **+
+   + * + * + * + * + * + * +   +
+---+---+---+---+---+---+---+---+
+ * + * +   + * +   +   +   +   +
+ **+ * +***+ **+***+ **+***+** +
+   + * +   +   +   + * +   + * +
+---+---+---+---+---+---+---+---+

5 1
+---+
+   +
+** +
+ * +
+---+
+ * +
+** +
+   +
+---+
+ * +
+ * +
+ * +
+---+
+ * +
+** +
+   +
+---+
+ * +
+ **+
+   +
+---+

5 2
+---+---+
+   + * +
+** +** +
+ * +   +
+---+---+
+   +   +
+** +** +
+ * + * +
+---+---+
+   +   +
+   +***+
+   +   +
+---+---+
+ * +   +
+** +   +
+   +   +
+---+---+
+ * +   +
+ **+** +
+   + * +
+---+---+

6 6
+---+---+---+---+---+---+
+ * + * +   +   +   +   +
+ **+ **+   +***+** +   +
+   +   +   +   + * +   +
+---+---+---+---+---+---+
+   +   + * +   + * + * +
+   +   + **+** + * + * +
+   +   +   + * + * + * +
+---+---+---+---+---+---+
+   + * +   + * + * +   +
+ **+ **+***+ **+ * +***+
+ * +   +   +   + * +   +
+---+---+---+---+---+---+
+   +   + * +   +   + * +
+ **+   + **+***+ **+ **+
+ * +   +   +   + * +   +
+---+---+---+---+---+---+
+   + * +   + * +   +   +
+***+ * +** + **+** +** +
+   + * + * +   + * + * +
+---+---+---+---+---+---+
+   +   + * +   + * +   +
+ **+   + **+   +** +** +
+ * +   +   +   +   + * +
+---+---+---+---+---+---+

2 3
+---+---+---+
+ * +   +   +
+ **+   +***+
+   +   +   +
+---+---+---+
+   + * +   +
+   +** +** +
+   +   + * +
+---+---+---+

2 8
+---+---+---+---+---+---+---+---+
+   +   + * + * +   + * +   + * +
+** +***+ **+ * +** + **+   + **+
+ * +   +   + * + * +   +   +   +
+---+---+---+---+---+---+---+---+
+ * + * +   + * +   + * +   + * +
+ * + **+** + **+ **+** +   + **+
+ * +   + * +   + * +   +   +   +
+---+---+---+---+---+---+---+---+

1 5
+---+---+---+---+---+
+   +   +   +   + * +
+** +** + **+***+ **+
+ * + * + * +   +   +
+---+---+---+---+---+

3 4
+---+---+---+---+
+   + * +   + * +
+** + **+** + * +
+ * +   + * + * +
+---+---+---+---+
+ * +   +   + * +
+ **+** +   + **+
+   + * +   +   +
+---+---+---+---+
+   + * +   +   +
+***+ **+   +** +
+   +   +   + * +
+---+---+---+---+

4 8
+---+---+---+---+---+---+---+---+
+ * +   +   +   + * + * +   +   +
+ **+***+ **+ **+** +** + **+ **+
+   +   + * + * +   +   + * + * +
+---+---+---+---+---+---+---+---+
+   +   +   +   + * +   +   +   +
+ **+** +***+ **+** +** +***+ **+
+ * + * +   + * +   + * +   + * +
+---+---+---+---+---+---+---+---+
+   +   +   + * +   + * +   +   +
+ **+***+ **+** + **+ * +***+** +
+ * +   + * +   + * + * +   + * +
+---+---+---+---+---+---+---+---+
+ * + * + * +   +   +   + * + * +
+ * +** + * +***+** +** +** + **+
+ * +   + * +   + * + * +   +   +
+---+---+---+---+---+---+---+---+

2 5
+---+---+---+---+---+
+ * + * + * +   + * +
+ **+** +** +   + **+
+   +   +   +   +   +
+---+---+---+---+---+
+   +   +   +   +   +
+***+** +** +   +** +
+   + * + * +   + * +
+---+---+---+---+---+

3 7
+---+---+---+---+---+---+---+
+   + * +   + * + * + * + * +
+** + **+***+** + **+ * +** +
+ * +   +   +   +   + * +   +
+---+---+---+---+---+---+---+
+   +   +   +   +   +   + * +
+***+***+   + **+***+   +** +
+   +   +   + * +   +   +   +
+---+---+---+---+---+---+---+
+   + * +   + * +   +   +   +
+***+ **+   + * +** +   +** +
+   +   +   + * + * +   + * +
+---+---+---+---+---+---+---+

2 7
+---+---+---+---+---+---+---+
+   +   +   +   +   +   +   +
+** +   +   +   +***+***+ **+
+ * +   +   +   +   +   + * +
+---+---+---+---+---+---+---+
+ * +   + * +   +   + * +   +
+ **+ **+** +   +***+ **+** +
+   + * +   +   +   +   + * +
+---+---+---+---+---+---+---+

4 8
+---+---+---+---+---+---+---+---+
+ * + * + * + * +   +   +   +   +
+ **+** + **+ **+***+** +***+ **+
+   +   +   +   +   + * +   + * +
+---+---+---+---+---+---+---+---+
+   + * +   +   +   +   + * + * +
+ **+ **+ **+***+ **+***+** + **+
+ * +   + * +   + * +   +   +   +
+---+---+---+---+---+---+---+---+
+ * +   +   + * +   +   +   + * +
+ **+** +   + * +   +***+** + **+
+   + * +   + * +   +   + * +   +
+---+---+---+---+---+---+---+---+
+   +   +   + * + * + * +   + * +
+   +   +** +** + **+ * +***+ **+
+   +   + * +   +   + * +   +   +
+---+---+---+---+---+---+---+---+

5 2
+---+---+
+ * + * +
+ **+** +
+   +   +
+---+---+
+ * + * +
+ * +** +
+ * +   +
+---+---+
+ * + * +
+** +** +
+   +   +
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+
+   + * +
+***+ **+
+   +   +
+---+---+

4 6
+---+---+---+---+---+---+
+   + * +   +   + * +   +
+** + **+   +   + **+***+
+ * +   +   +   +   +   +
+---+---+---+---+---+---+
+   + * +   + * +   +   +
+** + **+ **+** +** +   +
+ * +   + * +   + * +   +
+---+---+---+---+---+---+
+   + * + * +   + * + * +
+   + * +** +   +** +** +
+   + * +   +   +   +   +
+---+---+---+---+---+---+
+ * + * +   + * + * +   +
+** + * +***+ * +** +** +
+   + * +   + * +   + * +
+---+---+---+---+---+---+

2 8
+---+---+---+---+---+---+---+---+
+ * +   +   +   + * +   + * +   +
+ **+***+***+** +** + **+** +***+
+   +   +   + * +   + * +   +   +
+---+---+---+---+---+---+---+---+
+ * + * +   +   +   + * +   +   +
+ **+** +   +** + **+** +   +** +
+   +   +   + * + * +   +   + * +
+---+---+---+---+---+---+---+---+

5 6
+---+---+---+---+---+---+
+   + * + * +   +   + * +
+** +** +** + **+** + * +
+ * +   +   + * + * + * +
+---+---+---+---+---+---+
+ * +   + * + * +   +   +
+ * +***+** + **+ **+***+
+ * +   +   +   + * +   +
+---+---+---+---+---+---+
+ * +   + * +   +   + * +
+ * + **+ **+** +** + **+
+ * + * +   + * + * +   +
+---+---+---+---+---+---+
+   + * + * +   +   + * +
+** + **+ **+ **+** +** +
+ * +   +   + * + * +   +
+---+---+---+---+---+---+
+   + * +   +   + * + * +
+ **+ * +   +***+ * + **+
+ * + * +   +   + * +   +
+---+---+---+---+---+---+

3 4
+---+---+---+---+
+   + * +   +   +
+** + * +   +   +
+ * + * +   +   +
+---+---+---+---+
+ * +   + * +   +
+ * +***+ **+***+
+ * +   +   +   +
+---+---+---+---+
+ * +   + * +   +
+ **+** + **+** +
+   + * +   + * +
+---+---+---+---+

7 5
+---+---+---+---+---+
+ * +   +   +   +   +
+ **+ **+***+ **+   +
+   + * +   + * +   +
+---+---+---+---+---+
+   +   +   +   +   +
+   +** +** +** + **+
+   + * + * + * + * +
+---+---+---+---+---+
+   + * + * + * + * +
+   + **+ **+ **+ * +
+   +   +   +   + * +
+---+---+---+---+---+
+   +   + * +   +   +
+ **+***+ **+** +   +
+ * +   +   + * +   +
+---+---+---+---+---+
+   + * + * + * +   +
+ **+** + **+** +** +
+ * +   +   +   + * +
+---+---+---+---+---+
+   +   +   + * +   +
+ **+***+   +** +   +
+ * +   +   +   +   +
+---+---+---+---+---+
+   +   + * + * +   +
+ **+ **+** + * +** +
+ * + * +   + * + * +
+---+---+---+---+---+

5 2
+---+---+
+ * +   +
+ **+   +
+   +   +
+---+---+
+ * +   +
+ * +   +
+ * +   +
+---+---+
+ * +   +
+** +***+
+   +   +
+---+---+
+ * +   +
+ * +** +
+ * + * +
+---+---+
+   + * +
+***+ **+
+   +   +
+---+---+

7 7
+---+---+---+---+---+---+---+
+   + * +   + * + * + * + * +
+** + * +***+ **+ **+** + * +
+ * + * +   +   +   +   + * +
+---+---+---+---+---+---+---+
+   +   + * + * +   + * +   +
+** +***+ * + * +   + * + **+
+ * +   + * + * +   + * + * +
+---+---+---+---+---+---+---+
+ * +   + * +   + * + * + * +
+ **+ **+ * +   + **+** + **+
+   + * + * +   +   +   +   +
+---+---+---+---+---+---+---+
+   + * + * + * +   +   + * +
+***+ **+** +** +   +** + * +
+   +   +   +   +   + * + * +
+---+---+---+---+---+---+---+
+ * +   +   + * +   + * + * +
+ **+** +   +** + **+** + **+
+   + * +   +   + * +   +   +
+---+---+---+---+---+---+---+
+   +   + * +   + * +   +   +
+***+ **+ **+** + **+***+   +
+   + * +   + * +   +   +   +
+---+---+---+---+---+---+---+
+ * +   + * +   + * + * +   +
+ * +   +** + **+** + **+** +
+ * +   +   + * +   +   + * +
+---+---+---+---+---+---+---+

5 7
+---+---+---+---+---+---+---+
+ * +   + * +   +   + * + * +
+ **+** + **+   +** +** + **+
+   + * +   +   + * +   +   +
+---+---+---+---+---+---+---+
+ * + * +   + * +   +   +   +
+** + **+   + * +   +***+   +
+   +   +   + * +   +   +   +
+---+---+---+---+---+---+---+
+   +   +   +   + * +   +   +
+ **+** +** + **+ **+ **+** +
+ * + * + * + * +   + * + * +
+---+---+---+---+---+---+---+
+ * + * + * +   + * +   + * +
+** +** + **+***+ **+   + **+
+   +   +   +   +   +   +   +
+---+---+---+---+---+---+---+
+ * +   +   +   +   +   +   +
+** +   +** + **+   +***+** +
+   +   + * + * +   +   + * +
+---+---+---+---+---+---+---+

8 2
+---+---+
+ * + * +
+ **+ * +
+   + * +
+---+---+
+   + * +
+ **+** +
+ * +   +
+---+---+
+   + * +
+ **+ **+
+ * +   +
+---+---+
+ * +   +
+** +** +
+   + * +
+---+---+
+ * +   +
+ * +   +
+ * +   +
+---+---+
+   +   +
+***+***+
+   +   +
+---+---+
+   + * +
+ **+** +
+ * +   +
+---+---+
+   + * +
+   + **+
+   +   +
+---+---+

1 3
+---+---+---+
+ * + * + * +
+ **+** + **+
+   +   +   +
+---+---+---+

8 6
+---+---+---+---+---+---+
+   +   + * +   + * +   +
+** +***+** + **+** +** +
+ * +   +   + * +   + * +
+---+---+---+---+---+---+
+   +   + * +   + * + * +
+***+   + * +** + * + * +
+   +   + * + * + * + * +
+---+---+---+---+---+---+
+ * + * + * +   +   +   +
+** + * + **+** +** +** +
+   + * +   + * + * + * +
+---+---+---+---+---+---+
+   +   + * +   +   + * +
+***+ **+** +   +   +** +
+   + * +   +   +   +   +
+---+---+---+---+---+---+
+   +   +   +   + * +   +
+   +***+   +***+ * +   +
+   +   +   +   + * +   +
+---+---+---+---+---+---+
+ * + * +   +   + * + * +
+ * +** +** +** + **+ * +
+ * +   + * + * +   + * +
+---+---+---+---+---+---+
+ * +   +   + * +   +   +
+** + **+** +** +   +** +
+   + * + * +   +   + * +
+---+---+---+---+---+---+
+   + * +   +   + * +   +
+   + * +***+***+** +** +
+   + * +   +   +   + * +
+---+---+---+---+---+---+

8 1
+---+
+ * +
+ **+
+   +
+---+
+   +
+** +
+ * +
+---+
+   +
+** +
+ * +
+---+
+   +
+   +
+   +
+---+
+   +
+** +
+ * +
+---+
+ * +
+** +
+   +
+---+
+   +
+***+
+   +
+---+
+   +
+** +
+ * +
+---+

4 1
+---+
+   +
+** +
+ * +
+---+
+   +
+ **+
+ * +
+---+
+   +
+***+
+   +
+---+
+ * +
+ **+
+   +
+---+

5 7
+---+---+---+---+---+---+---+
+   +   +   + * + * +   +   +
+** +   +***+ **+ **+   +***+
+ * +   +   +   +   +   +   +
+---+---+---+---+---+---+---+
+   +   +   +   + * +   +   +
+** +***+***+** + **+ **+ **+
+ * +   +   + * +   + * + * +
+---+---+---+---+---+---+---+
+ * +   +   + * +   +   + * +
+ **+ **+ **+ * +***+   + **+
+   + * + * + * +   +   +   +
+---+---+---+---+---+---+---+
+   + * + * + * + * + * +   +
+** + **+ **+** + **+ * +***+
+ * +   +   +   +   + * +   +
+---+---+---+---+---+---+---+
+   +   +   + * +   +   + * +
+** +   + **+ * +   +***+ **+
+ * +   + * + * +   +   +   +
+---+---+---+---+---+---+---+

1 2
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+

5 7
+---+---+---+---+---+---+---+
+   +   + * + * +   + * + * +
+** +** +** + **+ **+ * + **+
+ * + * +   +   + * + * +   +
+---+---+---+---+---+---+---+
+   +   +   +   + * +   + * +
+** +   +   +   +** +** +** +
+ * +   +   +   +   + * +   +
+---+---+---+---+---+---+---+
+ * +   +   +   +   +   +   +
+ * +***+***+ **+***+***+** +
+ * +   +   + * +   +   + * +
+---+---+---+---+---+---+---+
+ * + * +   + * + * + * +   +
+ **+ **+ **+** + **+ **+ **+
+   +   + * +   +   +   + * +
+---+---+---+---+---+---+---+
+ * +   +   +   + * +   +   +
+** +   +   +***+ **+***+** +
+   +   +   +   +   +   + * +
+---+---+---+---+---+---+---+

4 4
+---+---+---+---+
+ * + * +   + * +
+ **+** + **+ **+
+   +   + * +   +
+---+---+---+---+
+   +   + * + * +
+***+   + * + **+
+   +   + * +   +
+---+---+---+---+
+   +   + * +   +
+ **+** + * +***+
+ * + * + * +   +
+---+---+---+---+
+   + * + * +   +
+ **+** + * +** +
+ * +   + * + * +
+---+---+---+---+

6 3
+---+---+---+
+ * +   +   +
+ **+** +** +
+   + * + * +
+---+---+---+
+   +   + * +
+   +** + * +
+   + * + * +
+---+---+---+
+ * + * + * +
+** + **+ * +
+   +   + * +
+---+---+---+
+ * + * + * +
+ * +** + **+
+ * +   +   +
+---+---+---+
+ * +   +   +
+ * +** +** +
+ * + * + * +
+---+---+---+
+ * +   +   +
+** +***+** +
+   +   + * +
+---+---+---+

6 6
+---+---+---+---+---+---+
+   + * + * +   +   + * +
+** + **+ * +***+   + **+
+ * +   + * +   +   +   +
+---+---+---+---+---+---+
+ * + * +   +   +   + * +
+** +** + **+   +   + **+
+   +   + * +   +   +   +
+---+---+---+---+---+---+
+   +   + * + * +   +   +
+** +** + * + * +   +***+
+ * + * + * + * +   +   +
+---+---+---+---+---+---+
+ * + * + * +   + * + * +
+** + **+** +   +** + * +
+   +   +   +   +   + * +
+---+---+---+---+---+---+
+ * +   + * +   +   +   +
+ **+ **+** +** + **+ **+
+   + * +   + * + * + * +
+---+---+---+---+---+---+
+   +   + * + * +   +   +
+   +***+** +** +***+** +
+   +   +   +   +   + * +
+---+---+---+---+---+---+

2 2
+---+---+
+ * + * +
+ **+ **+
+   +   +
+---+---+
+ * +   +
+** +** +
+   + * +
+---+---+

7 4
+---+---+---+---+
+   +   +   + * +
+** +** + **+** +
+ * + * + * +   +
+---+---+---+---+
+ * + * +   +   +
+** + * + **+***+
+   + * + * +   +
+---+---+---+---+
+ * +   +   +   +
+ **+** +***+ **+
+   + * +   + * +
+---+---+---+---+
+   +   + * +   +
+***+***+** +***+
+   +   +   +   +
+---+---+---+---+
+   + * + * +   +
+   +** + **+ **+
+   +   +   + * +
+---+---+---+---+
+   +   + * +   +
+ **+ **+ **+ **+
+ * + * +   + * +
+---+---+---+---+
+ * + * + * + * +
+ **+ * + **+ **+
+   + * +   +   +
+---+---+---+---+

7 1
+---+
+ * +
+ **+
+   +
+---+
+   +
+** +
+ * +
+---+
+   +
+***+
+   +
+---+
+   +
+** +
+ * +
+---+
+   +
+ **+
+ * +
+---+
+ * +
+ **+
+   +
+---+
+   +
+** +
+ * +
+---+

3 8
+---+---+---+---+---+---+---+---+
+   +   +   +   + * + * +   +   +
+** +** + **+   +** + **+***+***+
+ * + * + * +   +   +   +   +   +
+---+---+---+---+---+---+---+---+
+   + * + * + * +   +   +   +   +
+   + * + **+ * + **+***+***+   +
+   + * +   + * + * +   +   +   +
+---+---+---+---+---+---+---+---+
+   + * +   + * +   + * +   +   +
+** +** + **+ * + **+ * + **+** +
+ * +   + * + * + * + * + * + * +
+---+---+---+---+---+---+---+---+

7 4
+---+---+---+---+
+   +   +   + * +
+** + **+***+ * +
+ * + * +   + * +
+---+---+---+---+
+   +   + * +   +
+***+ **+ **+** +
+   + * +   + * +
+---+---+---+---+
+   + * + * +   +
+ **+ **+** +***+
+ * +   +   +   +
+---+---+---+---+
+ * +   +   + * +
+ * +** + **+ **+
+ * + * + * +   +
+---+---+---+---+
+   + * +   +   +
+ **+ **+** +   +
+ * +   + * +   +
+---+---+---+---+
+   + * + * +   +
+   + * +** +** +
+   + * +   + * +
+---+---+---+---+
+ * +   + * +   +
+** +** + **+** +
+   + * +   + * +
+---+---+---+---+

5 5
+---+---+---+---+---+
+ * +   +   + * + * +
+ **+ **+** +** +** +
+   + * + * +   +   +
+---+---+---+---+---+
+   + * + * +   +   +
+***+ * + * +** +***+
+   + * + * + * +   +
+---+---+---+---+---+
+   +   + * + * + * +
+***+ **+** + * +** +
+   + * +   + * +   +
+---+---+---+---+---+
+ * + * +   +   +   +
+** +** +** +***+ **+
+   +   + * +   + * +
+---+---+---+---+---+
+ * +   + * + * +   +
+ **+** + * + **+** +
+   + * + * +   + * +
+---+---+---+---+---+

4 8
+---+---+---+---+---+---+---+---+
+   + * + * +   +   + * + * + * +
+** + **+** +   + **+** + * + **+
+ * +   +   +   + * +   + * +   +
+---+---+---+---+---+---+---+---+
+ * +   +   +   +   + * + * +   +
+** +   +** +***+   + * + * +** +
+   +   + * +   +   + * + * + * +
+---+---+---+---+---+---+---+---+
+ * +   +   +   + * +   +   +   +
+ **+ **+** +   + * +   +   +***+
+   + * + * +   + * +   +   +   +
+---+---+---+---+---+---+---+---+
+   +   +   + * + * +   + * + * +
+   +** +***+** +** +***+** + **+
+   + * +   +   +   +   +   +   +
+---+---+---+---+---+---+---+---+

2 8
+---+---+---+---+---+---+---+---+
+   + * +   +   +   +   +   + * +
+** +** +** +** + **+***+   + **+
+ * +   + * + * + * +   +   +   +
+---+---+---+---+---+---+---+---+
+   +   +   + * + * + * + * +   +
+** +***+   + * + **+ **+ * +** +
+ * +   +   + * +   +   + * + * +
+---+---+---+---+---+---+---+---+

2 2
+---+---+
+ * +   +
+ **+** +
+   + * +
+---+---+
+ * + * +
+ **+ **+
+   +   +
+---+---+

4 2
+---+---+
+   + * +
+** + * +
+ * + * +
+---+---+
+   +   +
+***+***+
+   +   +
+---+---+
+ * + * +
+ * + **+
+ * +   +
+---+---+
+ * +   +
+** +** +
+   + * +
+---+---+

2 7
+---+---+---+---+---+---+---+
+ * +   + * + * + * +   +   +
+ **+ **+ **+ * + * +***+ **+
+   + * +   + * + * +   + * +
+---+---+---+---+---+---+---+
+   + * +   +   + * +   +   +
+** + * +***+** +** +   +** +
+ * + * +   + * +   +   + * +
+---+---+---+---+---+---+---+

6 3
+---+---+---+
+   +   + * +
+** + **+ **+
+ * + * +   +
+---+---+---+
+ * +   + * +
+ **+   + * +
+   +   + * +
+---+---+---+
+   + * +   +
+   +** +** +
+   +   + * +
+---+---+---+
+   +   +   +
+ **+** +***+
+ * + * +   +
+---+---+---+
+   + * +   +
+** + **+   +
+ * +   +   +
+---+---+---+
+ * +   +   +
+ * +***+** +
+ * +   + * +
+---+---+---+

4 3
+---+---+---+
+ * + * +   +
+ **+** +***+
+   +   +   +
+---+---+---+
+ * +   +   +
+ **+ **+***+
+   + * +   +
+---+---+---+
+ * +   +   +
+** + **+** +
+   + * + * +
+---+---+---+
+   +   +   +
+   +   +** +
+   +   + * +
+---+---+---+

1 6
+---+---+---+---+---+---+
+ * + * +   +   +   + * +
+ **+** +** +   +** + **+
+   +   + * +   + * +   +
+---+---+---+---+---+---+

6 1
+---+
+   +
+** +
+ * +
+---+
+   +
+   +
+   +
+---+
+   +
+***+
+   +
+---+
+   +
+***+
+   +
+---+
+   +
+ **+
+ * +
+---+
+   +
+** +
+ * +
+---+

2 3
+---+---+---+
+   + * + * +
+** + * + **+
+ * + * +   +
+---+---+---+
+   +   + * +
+***+   + **+
+   +   +   +
+---+---+---+

5 5
+---+---+---+---+---+
+   + * +   +   + * +
+** + **+***+** + **+
+ * +   +   + * +   +
+---+---+---+---+---+
+   +   +   +   +   +
+***+** +   +** +***+
+   + * +   + * +   +
+---+---+---+---+---+
+   +   + * + * + * +
+** + **+ **+ * +** +
+ * + * +   + * +   +
+---+---+---+---+---+
+ * + * +   + * +   +
+** +** +   +** +***+
+   +   +   +   +   +
+---+---+---+---+---+
+ * + * + * +   + * +
+ * + **+** +** + **+
+ * +   +   + * +   +
+---+---+---+---+---+

1 3
+---+---+---+
+ * + * + * +
+ **+ **+ **+
+   +   +   +
+---+---+---+

4 3
+---+---+---+
+   +   +   +
+** +** +** +
+ * + * + * +
+---+---+---+
+   + * +   +
+ **+ * +** +
+ * + * + * +
+---+---+---+
+ * +   + * +
+** + **+ * +
+   + * + * +
+---+---+---+
+ * + * + * +
+ * +** + **+
+ * +   +   +
+---+---+---+

6 6
+---+---+---+---+---+---+
+ * + * +   +   + * + * +
+ **+ * + **+   +** +** +
+   + * + * +   +   +   +
+---+---+---+---+---+---+
+   + * + * + * +   + * +
+ **+ **+ **+ **+***+** +
+ * +   +   +   +   +   +
+---+---+---+---+---+---+
+ * +   +   +   +   + * +
+ * +   +   +** +** + * +
+ * +   +   + * + * + * +
+---+---+---+---+---+---+
+   + * + * + * + * +   +
+   + **+ * + **+ **+   +
+   +   + * +   +   +   +
+---+---+---+---+---+---+
+   +   +   + * + * + * +
+** +   +   + **+ **+** +
+ * +   +   +   +   +   +
+---+---+---+---+---+---+
+   +   +   +   +   + * +
+   +   +** +   + **+ **+
+   +   + * +   + * +   +
+---+---+---+---+---+---+

8 6
+---+---+---+---+---+---+
+   + * +   + * + * + * +
+** + **+** + * +** + **+
+ * +   + * + * +   +   +
+---+---+---+---+---+---+
+ * +   + * + * + * +   +
+** + **+ **+ **+** +** +
+   + * +   +   +   + * +
+---+---+---+---+---+---+
+ * + * + * + * + * + * +
+ * +** + **+** +** +** +
+ * +   +   +   +   +   +
+---+---+---+---+---+---+
+   +   +   +   +   + * +
+   + **+ **+***+ **+ **+
+   + * + * +   + * +   +
+---+---+---+---+---+---+
+ * +   +   + * +   +   +
+ * +   +***+** + **+** +
+ * +   +   +   + * + * +
+---+---+---+---+---+---+
+ * +   +   + * + * +   +
+ * +***+ **+ **+ **+** +
+ * +   + * +   +   + * +
+---+---+---+---+---+---+
+   + * +   + * +   +   +
+   + **+ **+ **+***+ **+
+   +   + * +   +   + * +
+---+---+---+---+---+---+
+ * + * +   +   +   + * +
+ * +** + **+***+ **+ **+
+ * +   + * +   + * +   +
+---+---+---+---+---+---+

4 6
+---+---+---+---+---+---+
+   + * +   +   +   + * +
+** + **+   + **+** + * +
+ * +   +   + * + * + * +
+---+---+---+---+---+---+
+   + * + * +   +   + * +
+   + * + **+ **+ **+ * +
+   + * +   + * + * + * +
+---+---+---+---+---+---+
+ * + * + * +   + * + * +
+** + **+** +** + * + **+
+   +   +   + * + * +   +
+---+---+---+---+---+---+
+   +   +   +   + * + * +
+** +***+ **+   +** + **+
+ * +   + * +   +   +   +
+---+---+---+---+---+---+

4 4
+---+---+---+---+
+   + * + * +   +
+** + * + **+***+
+ * + * +   +   +
+---+---+---+---+
+   +   +   + * +
+***+***+   + * +
+   +   +   + * +
+---+---+---+---+
+   + * +   +   +
+   + **+** +***+
+   +   + * +   +
+---+---+---+---+
+   + * +   +   +
+ **+** +***+** +
+ * +   +   + * +
+---+---+---+---+

4 5
+---+---+---+---+---+
+   +   + * + * +   +
+** +***+ * + * +** +
+ * +   + * + * + * +
+---+---+---+---+---+
+ * +   +   + * + * +
+ **+ **+ **+** + **+
+   + * + * +   +   +
+---+---+---+---+---+
+ * + * + * +   +   +
+ **+ * + * +** + **+
+   + * + * + * + * +
+---+---+---+---+---+
+   + * +   + * +   +
+ **+** + **+ **+** +
+ * +   + * +   + * +
+---+---+---+---+---+

5 7
+---+---+---+---+---+---+---+
+   +   + * + * +   +   + * +
+** +** +** + * +** +** + **+
+ * + * +   + * + * + * +   +
+---+---+---+---+---+---+---+
+   +   + * + * +   + * +   +
+ **+ **+ * + **+   + * +***+
+ * + * + * +   +   + * +   +
+---+---+---+---+---+---+---+
+ * + * +   +   + * +   +   +
+ **+ **+** +***+ **+   +   +
+   +   + * +   +   +   +   +
+---+---+---+---+---+---+---+
+ * + * +   + * + * +   +   +
+ * +** + **+** + * +***+ **+
+ * +   + * +   + * +   + * +
+---+---+---+---+---+---+---+
+ * +   +   +   +   + * + * +
+** +** +** +   +   +** + **+
+   + * + * +   +   +   +   +
+---+---+---+---+---+---+---+

3 2
+---+---+
+ * + * +
+ **+** +
+   +   +
+---+---+
+ * + * +
+** + * +
+   + * +
+---+---+
+   +   +
+ **+** +
+ * + * +
+---+---+

2 8
+---+---+---+---+---+---+---+---+
+ * + * +   +   +   +   + * + * +
+ **+ * +** +***+***+***+ * + **+
+   + * + * +   +   +   + * +   +
+---+---+---+---+---+---+---+---+
+ * +   + * +   + * +   +   +   +
+** +** + * +***+** +** + **+** +
+   + * + * +   +   + * + * + * +
+---+---+---+---+---+---+---+---+

6 5
+---+---+---+---+---+
+ * +   +   +   +   +
+ **+   + **+ **+   +
+   +   + * + * +   +
+---+---+---+---+---+
+ * + * +   +   + * +
+ * + **+***+***+ * +
+ * +   +   +   + * +
+---+---+---+---+---+
+   + * + * +   +   +
+** + **+ * +   + **+
+ * +   + * +   + * +
+---+---+---+---+---+
+ * +   +   +   +   +
+ * + **+***+***+   +
+ * + * +   +   +   +
+---+---+---+---+---+
+   +   + * + * +   +
+   +** + * +** +***+
+   + * + * +   +   +
+---+---+---+---+---+
+   +   +   + * +   +
+***+** + **+ * +** +
+   + * + * + * + * +
+---+---+---+---+---+

3 4
+---+---+---+---+
+   +   +   + * +
+** +   +***+ * +
+ * +   +   + * +
+---+---+---+---+
+   +   +   + * +
+ **+   +***+ * +
+ * +   +   + * +
+---+---+---+---+
+ * + * +   +   +
+ **+** +***+** +
+   +   +   + * +
+---+---+---+---+

2 2
+---+---+
+   +   +
+** + **+
+ * + * +
+---+---+
+   + * +
+ **+ **+
+ * +   +
+---+---+

2 5
+---+---+---+---+---+
+   +   +   +   + * +
+** + **+   +** +** +
+ * + * +   + * +   +
+---+---+---+---+---+
+ * +   +   +   + * +
+ * + **+   +** + **+
+ * + * +   + * +   +
+---+---+---+---+---+

8 3
+---+---+---+
+ * +   + * +
+ **+   +** +
+   +   +   +
+---+---+---+
+   + * + * +
+***+ * +** +
+   + * +   +
+---+---+---+
+   +   +   +
+** +   +** +
+ * +   + * +
+---+---+---+
+ * +   +   +
+** +   +***+
+   +   +   +
+---+---+---+
+   + * + * +
+   + **+ * +
+   +   + * +
+---+---+---+
+   +   + * +
+** +** + * +
+ * + * + * +
+---+---+---+
+   +   +   +
+   +   +** +
+   +   + * +
+---+---+---+
+ * +   + * +
+ **+***+ **+
+   +   +   +
+---+---+---+

5 3
+---+---+---+
+ * +   + * +
+ **+ **+ * +
+   + * + * +
+---+---+---+
+ * + * + * +
+** + **+ **+
+   +   +   +
+---+---+---+
+   +   +   +
+ **+   +***+
+ * +   +   +
+---+---+---+
+   + * + * +
+ **+ * + * +
+ * + * + * +
+---+---+---+
+   +   +   +
+***+***+** +
+   +   + * +
+---+---+---+

2 4
+---+---+---+---+
+   + * +   +   +
+** + * +***+ **+
+ * + * +   + * +
+---+---+---+---+
+   + * +   +   +
+   + **+***+** +
+   +   +   + * +
+---+---+---+---+

3 2
+---+---+
+   + * +
+** + **+
+ * +   +
+---+---+
+   +   +
+** +   +
+ * +   +
+---+---+
+ * + * +
+** + **+
+   +   +
+---+---+

3 4
+---+---+---+---+
+   +   +   +   +
+** +   +   + **+
+ * +   +   + * +
+---+---+---+---+
+   +   + * + * +
+ **+***+ * + **+
+ * +   + * +   +
+---+---+---+---+
+ * +   +   +   +
+** + **+ **+** +
+   + * + * + * +
+---+---+---+---+
``````
AC out:

Code: Select all

``````Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 1
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 4
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 3
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 1
Number of solutions: 1
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 4
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 1
Number of solutions: 2
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 2
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 2
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 1
Number of solutions: 18
Number of solutions: 2
Number of solutions: 0
Number of solutions: 2
Number of solutions: 1
Number of solutions: 1
Number of solutions: 0
Number of solutions: 0
Number of solutions: 0
Number of solutions: 2
Number of solutions: 0
Number of solutions: 0
Number of solutions: 1
Number of solutions: 1
Number of solutions: 0
Number of solutions: 1
``````