#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 120;
int a[N], b[N];
queue<int> q, ans;
char c[N][N];
int mat[N][N];
int n;
int main() {
  while (~scanf("%d", &n)) {
    while (!q.empty()) q.pop();
    while (!ans.empty()) ans.pop();
    for (int i = 1; i <= n; ++i) {
      scanf("%s", c[i] + 1);
      for (int j = 1; j <= n; ++j) {
        mat[i][j] = c[i][j] - '0';
      }
    }
    int x = 0, cnt = 0;
    for (int i = 1; i <= n; ++i) {
      b[i] = 0;
      scanf("%d", &a[i]);
      x += (a[i] != 0);
      if (!a[i]) {
        cnt++;
        ans.push(i);
        q.push(i);
      }
    }
    if (x == n) {
      printf("0\n\n");
      continue;
    }
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (int i = 1; i <= n; ++i) {
        if (mat[now][i]) {
          b[i]++;
          if (b[i] == a[i]) {
            cnt++;
            q.push(i);
            ans.push(i);
          }
        }
      }
    }
    printf("%d\n", cnt);
    while (!ans.empty()) {
      printf("%d ", ans.front());
      ans.pop();
    }
    puts("");
  }
  return 0;
}
