#include <bits/stdc++.h>
using namespace std;
char s[103];
int a[103], Ans[103], M;
vector<int> G[103];
queue<int> Q;
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= N; j++)
      if (s[j] == '1') G[i].push_back(j);
  }
  for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= N; i++)
    if (!a[i]) Q.push(i);
  if (Q.empty()) {
    puts("0");
    return 0;
  }
  while (!Q.empty()) {
    int u = Q.front();
    Ans[++M] = u;
    Q.pop();
    for (auto v : G[u])
      if (!(--a[v])) Q.push(v);
  }
  printf("%d\n", M);
  for (int i = 1; i <= M; i++) printf("%d%c", Ans[i], " \n"[i == M]);
  return 0;
}
