#include <bits/stdc++.h>
using namespace std;
char str[1010][1010];
int a[1010];
int ans[1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", str[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int l = 0;
  for (int i = 0; i < n; i++) {
    int v = -1;
    for (int j = 0; j < n; j++) {
      if (a[j] == 0) {
        v = j;
        break;
      }
    }
    if (v == -1) break;
    ans[l++] = v;
    for (int j = 0; j < n; j++) {
      if (str[v][j] == '1') a[j]--;
    }
  }
  printf("%d\n", l);
  for (int i = 0; i < l; i++) {
    if (i) printf(" ");
    printf("%d", ans[i] + 1);
  }
  printf("\n");
}
