#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
char c[110][110];
int a[110], f[110];
void solve(int n) {
  int i, j, k, q, w, b, l = 0, r = 0, m, x1, x2, y1, y2;
  gets(c[0]);
  for (i = 0; i < n; i++) gets(c[i]);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    f[i] = 0;
  }
  for (i = 0; i < n; i++) {
    l = -1;
    for (j = 0; j < n; j++)
      if (a[j] == 0) l = j;
    if (l == -1) {
      l = 0;
      for (j = 0; j < n; j++)
        if (f[j] == 1) l++;
      printf("%d\n", l);
      for (j = 0; j < n; j++)
        if (f[j] == 1) printf("%d ", j + 1);
      printf("\n");
      return;
    }
    for (j = 0; j < n; j++)
      if (c[l][j] == '1') a[j]--;
    f[l] = 1;
  }
  l = 0;
  for (j = 0; j < n; j++)
    if (f[j] == 1) l++;
  printf("%d\n", l);
  for (j = 0; j < n; j++)
    if (f[j] == 1) printf("%d ", j + 1);
  printf("\n");
}
int main() {
#pragma comment(linker, "/STACK:1073741824")
  int n, m, k;
  while (scanf("%d", &n) != EOF) solve(n);
  return 0;
}
