#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> a;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    a.push_back(s);
  }
  vector<int> g;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    g.push_back(x);
  }
  vector<int> ans;
  while (1) {
    int i = 0;
    for (i = 0; i < n; ++i) {
      if (!g[i]) {
        break;
      }
    }
    if (i == n) {
      break;
    }
    ans.push_back(i);
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == '1') {
        --g[j];
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] + 1 << " ";
  }
}
