#include <bits/stdc++.h>
using namespace std;
int n = 0;
int arr[109];
bool vis[109];
int las[109];
string s[109];
vector<int> v;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int nw = 0;
  while (1 == 1) {
    nw = -1;
    for (int i = 0; i < n; i++) {
      if (vis[i] == 0 && las[i] == arr[i]) {
        nw = i;
        break;
      }
    }
    if (nw == -1) break;
    v.push_back(nw + 1);
    for (int i = 0; i < n; i++) {
      if (s[nw][i] == '1') las[i]++;
    }
  }
  int size = v.size();
  cout << size << endl;
  for (int i = 0; i < size; i++) cout << v[i] << " ";
  cout << endl;
  return 0;
}
