#include <bits/stdc++.h>
using namespace std;
string a[1010];
int n;
int b[1000];
int cnt[1000] = {0};
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int j = 1; j <= n; j++) cin >> cnt[j];
  std::vector<int> res;
  for (int it = 0; it < n; it++) {
    for (int i = 1; i <= n; i++)
      if (cnt[i] == 0) {
        for (int j = 0; j < n; j++) cnt[j + 1] -= (a[i][j] == '1');
        res.push_back(i);
      }
  }
  int size = res.size();
  if (size == 0) {
    cout << 0 << endl;
    cout << endl;
    return 0;
  }
  cout << size << endl;
  for (int i = 0; i < res.size(); i++) {
    cout << res[i] << " ";
  }
  return 0;
}
