#include <bits/stdc++.h>
using namespace std;
queue<long long> q;
bool vis[101];
long long ans[101], tot;
long long n, matrix[101][101], num[101];
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      scanf("%1lld", &matrix[i][j]);
    }
  }
  for (long long i = 1; i <= n; i++) scanf("%lld", &num[i]);
  for (long long i = 1; i <= n; i++) {
    if (num[i] == 0) q.push(i), vis[i] = 1;
  }
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    if (num[u] != 0) continue;
    ans[++tot] = u;
    for (long long i = 1; i <= n; i++) {
      if (!matrix[u][i] || vis[i]) continue;
      num[i] -= 1;
      if (num[i] == 0) {
        q.push(i);
        vis[i] = 1;
      }
    }
  }
  printf("%lld\n", tot);
  for (long long i = 1; i <= tot; i++) printf("%lld ", ans[i]);
  return 0;
}
