#include <bits/stdc++.h>
using namespace std;
char con[105][105];
bool used[105];
int need[105];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < int(n); ++i) {
    scanf("%s", con[i]);
  }
  for (int i = (0); i < int(n); ++i) scanf("%d", need + i);
  int ans = 0;
  while (true) {
    bool ok = 1;
    for (int i = (0); i < int(n); ++i) {
      if (need[i] != 0) continue;
      used[i] = 1;
      ok = 0;
      ++ans;
      for (int j = (0); j < int(n); ++j) {
        if (con[i][j] == '0') continue;
        --need[j];
      }
    }
    if (ok) {
      printf("%d\n", ans);
      for (int i = (0); i < int(n); ++i) {
        if (!used[i]) continue;
        printf("%d ", i + 1);
      }
      printf("\n");
      return 0;
    }
  }
}
