#include <bits/stdc++.h>
using namespace std;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
void setupIO(const string &PROB = "") {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  if (PROB.length() != 0) {
    ifstream infile(PROB + ".in");
    if (infile.good()) {
      freopen((PROB + ".in").c_str(), "r", stdin);
      freopen((PROB + ".out").c_str(), "w", stdout);
    }
  }
}
int main() {
  setupIO();
  int n;
  cin >> n;
  int A[n][n];
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      char c;
      cin >> c;
      A[i][j] = c == '1';
    }
  }
  int B[n];
  for (int i = 0; i < (n); i++) cin >> B[i];
  bool C[n];
  for (int i = 0; i < n; i++) C[i] = false;
  ;
  while (true) {
    int tgt = -1;
    for (int i = 0; i < (n); i++) {
      if (B[i] == 0) {
        tgt = i;
        break;
      }
    }
    if (tgt == -1) break;
    assert(!C[tgt]);
    for (int i = 0; i < (n); i++) {
      if (A[tgt][i]) B[i]--;
    }
    C[tgt] = true;
  }
  vector<int> ans;
  for (int i = 0; i < (n); i++)
    if (C[i]) ans.push_back(i);
  cout << ans.size() << endl;
  for (int i = 0; i < (ans.size()); i++) {
    if (i != 0) cout << " ";
    cout << ans[i] + 1;
  }
  cout << endl;
  return 0;
}
