#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn], ans[maxn], res, n, cur;
char s[maxn][maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    cur = 0;
    for (int j = 1; j <= n; j++)
      if (a[j] == 0) {
        cur = j;
        break;
      }
    if (!cur) break;
    ans[++res] = cur;
    for (int j = 1; j <= n; j++)
      if (s[cur][j] == '1') a[j]--;
  }
  printf("%d\n", res);
  for (int i = 1; i <= res; i++) printf("%d ", ans[i]);
  return 0;
}
