#include <bits/stdc++.h>
using namespace std;
int n;
int matrix[102][102];
int t[102];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char ch;
      cin >> ch;
      matrix[i][j] = ch - '0';
    }
  }
  for (int i = 0; i < n; i++) cin >> t[i];
  vector<int> ans;
  bool cont = true;
  while (cont) {
    cont = false;
    for (int i = 0; i < n; i++) {
      if (t[i] == 0) {
        ans.push_back(i);
        cont = true;
        for (int j = 0; j < n; j++) {
          if (matrix[i][j] == 1) t[j]--;
        }
      }
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
  cout << "\n";
  return 0;
}
