#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string adj[n];
  for (int i = 0; i < n; i++) {
    cin >> adj[i];
  }
  int guess[n];
  for (int i = 0; i < n; i++) {
    cin >> guess[i];
  }
  bool coming[n];
  for (int i = 0; i < n; i++) {
    coming[i] = false;
  }
  for (int q = 0; q < n; q++) {
    for (int i = 0; i < n; i++) {
      if (guess[i] == 0) {
        coming[i] = true;
        for (int j = 0; j < n; j++) {
          if (adj[i][j] - '0') {
            guess[j]--;
          }
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (coming[i]) {
      count++;
    }
  }
  cout << count << endl;
  for (int i = 0; i < n; i++) {
    if (coming[i]) {
      cout << i + 1 << " ";
    }
  }
  cout << endl;
}
