#include <bits/stdc++.h>
int n, a[100 + 9];
int adj[100 + 9][100 + 9];
int tot, ans[100 + 9];
int findz() {
  for (int i = 0; i < n; ++i)
    if (!a[i]) return i;
  return -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%1d", adj[i] + j);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int p = findz(); ~p; p = findz()) {
    ans[tot++] = p;
    for (int i = 0; i < n; ++i) a[i] -= adj[p][i];
  }
  printf("%d\n", tot);
  while (tot--) printf("%d%c", ans[tot] + 1, " \n"[!tot]);
  return 0;
}
