#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int> > G(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++)
      if (s[j] == '1') G[i][j] = 1;
  }
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<int> sol;
  queue<int> q;
  while (sol.size() < n) {
    for (int i = 0; i < n; i++)
      if (v[i] == 0) q.push(i);
    if (q.size() == 0) break;
    while (!q.empty()) {
      int pos = q.front();
      q.pop();
      sol.push_back(pos + 1);
      for (int i = 0; i < n; i++) {
        if (G[pos][i] == 1) v[i]--;
      }
    }
  }
  cout << sol.size() << endl;
  sort(sol.begin(), sol.end());
  for (int i = 0; i < sol.size(); i++) {
    if (i) cout << ' ';
    cout << sol[i];
  }
  cout << endl;
}
