#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[200][200];
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  int guess[100];
  for (int i = 0; i < n; i++) {
    scanf("%d", &guess[i]);
  }
  int reality[100] = {};
  int i;
  vector<int> rs;
  while (true) {
    for (i = 0; i < n; i++)
      if (guess[i] == reality[i]) break;
    if (i == n) break;
    rs.push_back(i);
    for (int j = 0; j < n; j++) reality[j] += (a[i][j] - '0');
  }
  cout << rs.size() << endl;
  if (rs.size() > 0) {
    for (unsigned int i = 0; i < rs.size() - 1; i++) printf("%d ", rs[i] + 1);
    printf("%d", rs[rs.size() - 1] + 1);
  }
  return 0;
}
