#include <bits/stdc++.h>
using namespace std;
int mm[100][100];
int ar[100];
int main() {
  int n;
  scanf("%d", &n);
  for (int lx = 0; lx < n; lx++) {
    char tmp[110];
    scanf("%s", tmp);
    for (int ly = 0; ly < n; ly++) mm[lx][ly] = tmp[ly] == '1';
  }
  for (int lx = 0; lx < n; lx++) scanf("%d", ar + lx);
  vector<int> ans;
  bool inans[100] = {0};
  while (1) {
    vector<int> zset;
    for (int lx = 0; lx < n; lx++)
      if (ar[lx] == 0 and !inans[lx])
        zset.push_back(lx), ans.push_back(lx), inans[lx] = 1;
    if (zset.size() == 0) break;
    for (int ii : zset) {
      for (int lx = 0; lx < n; lx++)
        if (mm[ii][lx] and ar[lx]) ar[lx]--;
    }
  }
  printf("%d\n", (int)ans.size());
  for (int ii : ans) printf("%d ", ii + 1);
  puts("");
  return 0;
}
