#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
char c[MAXN + 10][MAXN + 10];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%s", c[i]);
  }
  vector<int> p(n), res;
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &p[i]);
  }
  while (1) {
    int v = -1;
    for (int i = 0; i < (n); ++i) {
      if (p[i] == 0) {
        v = i;
      }
    }
    if (v == -1) {
      break;
    }
    for (int i = 0; i < (n); ++i) {
      if (c[v][i] == '1') {
        --p[i];
      }
    }
    res.push_back(v);
  }
  printf("%d\n", ((int)((res).size())));
  for (int x : res) {
    printf("%d ", x + 1);
  }
  puts("");
  return 0;
}
