#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], cur[N];
string s[N];
vector<int> ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  while (true) {
    int no = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] == cur[i]) {
        no = i;
        break;
      }
    }
    if (no == -1) break;
    ans.push_back(no + 1);
    for (int i = 0; i < n; i++) {
      if (s[no][i] == '1') {
        cur[i]++;
      }
    }
  }
  cout << ans.size() << endl;
  for (size_t i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
