#include<iostream>
const int maxN = 8;
int map[maxN], cnt = 0;
bool check(const int &x) {
for (int i = 0; i < x; ++i)
if (map[x] == map[i] || x - i == map[x] - map[i] || x - i == map[i] - map[x])return false;
return true;
}
void dfs(int pos) {
if (pos == maxN) {
++cnt;
printf("no.%d\n", cnt);
for (int i = 0; i < maxN; ++i)
for (int j = 0; j < maxN; ++j) {
printf("%d", map[i] == j ? 1 : 0);
if (j == maxN - 1)printf("\n");
else printf(" ");
}
printf("\n");
return;
}
for (int i = 0; i < maxN; ++i) {
map[pos] = i;
if (!check(pos))continue;
dfs(pos + 1);
}
}
int main() {
dfs(0);
printf("%d\n", cnt);
return 0;
}