#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char a[110][110];
  int s[110];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &s[i]);
  vector<int> ans;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = 0; i < n; i++)
      if (s[i] == 0) {
        flag = true;
        ans.push_back(i);
        for (int j = 0; j < n; j++)
          if (a[i][j] == '1') s[j]--;
      }
  }
  printf("%u\n", ans.size());
  for (int i = 0; i < (int)ans.size(); i++) printf("%d ", ans[i] + 1);
  return 0;
}
