#include <bits/stdc++.h>
using namespace std;
int ar[109][109], pr[109], done[109];
vector<int> vec;
queue<int> Q;
int main() {
  int i, j, k, l, N, M, K, flag, ans, now;
  char ch;
  cin >> N;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      cin >> ch;
      ar[i][j] = ch - '0';
    }
  }
  flag = 0;
  for (i = 1; i <= N; i++) {
    cin >> pr[i];
    if (pr[i] == 0 && flag == 0) {
      flag = 1;
      Q.push(i);
    }
  }
  if (flag == 0) {
    cout << "0\n";
    return 0;
  }
  ans = 0;
  while (!Q.empty()) {
    now = Q.front();
    Q.pop();
    if (done[now]) continue;
    vec.push_back(now);
    ans++;
    done[now] = 1;
    for (i = 1; i <= N; i++) {
      if (i == now) continue;
      if (done[i]) continue;
      if (ar[now][i]) pr[i]--;
      if (pr[i] == 0) Q.push(i);
    }
  }
  cout << ans << endl;
  sort(vec.begin(), vec.end());
  for (i = 0; i < ans; i++) cout << vec[i] << ' ';
  cout << endl;
}
