#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool rd(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void pt(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) pt(x / 10);
  putchar(x % 10 + '0');
}
char s[110][110];
int a[110];
vector<int> ans;
int n;
int main() {
  rd(n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) rd(a[i]);
  for (int i = 0; i < n; i++) {
    int t = -1;
    for (int j = 0; j < n; j++)
      if (a[j] == 0) {
        t = j;
        break;
      }
    if (t == -1) break;
    ans.push_back(t);
    for (int j = 0; j < n; j++) a[j] -= s[t][j] - '0';
  }
  pt(int(ans.size()));
  putchar('\n');
  for (int i = 0; i < ans.size(); i++) pt(ans[i] + 1), putchar(' ');
  return 0;
}
