#include <bits/stdc++.h>
using namespace std;
int n;
int init[110];
string lst[110];
vector<int> fin;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = (int)0; i < (int)n; ++i) cin >> lst[i];
  for (int i = (int)0; i < (int)n; ++i) cin >> init[i];
  bool flag = 1;
  while (flag) {
    flag = 0;
    for (int i = (int)0; i < (int)n; ++i)
      if (init[i] == 0) {
        flag = 1;
        fin.push_back(i + 1);
        for (int j = (int)0; j < (int)n; ++j) init[j] -= lst[i][j] - '0';
      }
  }
  cout << fin.size() << endl;
  for (int ele : fin) cout << ele << " ";
  return 0;
}
