#include <bits/stdc++.h>
template <typename A, typename B>
inline void amax(A &x, B y) {
  if (x < y) x = y;
}
template <typename A, typename B>
inline void amin(A &x, B y) {
  if (!(x < y)) x = y;
}
using namespace std;
int n;
char s[109][109];
int A[109];
int shumat[109];
vector<int> ans;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) scanf("%d", A + i);
  while (1) {
    int pos = -1;
    for (int i = 0; i < n; i++)
      if (shumat[i] == A[i]) {
        pos = i;
        break;
      }
    if (pos == -1) break;
    ans.push_back(pos + 1);
    for (int i = 0; i < n; i++) shumat[i] += s[pos][i] - '0';
  }
  printf("%d\n", ans.size());
  for (__typeof((ans).begin()) i = (ans).begin(); i != (ans).end(); i++)
    printf("%d ", *i);
}
