#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<char> > people_graph(n, vector<char>(n));
  vector<int> result(100);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> people_graph[i][j];
    }
  }
  vector<int> guesses(n);
  for (int i = 0; i < n; i++) {
    cin >> guesses[i];
  }
  int r = 0;
  while (true) {
    bool f = false;
    for (int i = 0; i < n; i++)
      if (guesses[i] == 0) {
        result[r++] = i;
        for (int j = 0; j < n; j++) guesses[j] -= people_graph[i][j] - '0';
        f = true;
      }
    if (!f) break;
  }
  cout << r << '\n';
  for (int i = 0; i < r; i++) {
    cout << 1 + result[i] << ' ';
  }
}
