#include <bits/stdc++.h>
using namespace std;
int main() {
  int label = -1, tot = 0;
  int unpresent[105];
  int n, contact[105][105];
  bool con = 0;
  int pre[105];
  string tem;
  cin >> n;
  memset(contact, 0, sizeof(contact));
  for (int i = 0; i < n; i++) {
    cin >> tem;
    for (int j = 0; j < tem.size(); j++) contact[i][j] = tem[j] - '0';
  }
  memset(unpresent, 0, sizeof(unpresent));
  memset(pre, 0, sizeof(pre));
  for (int i = 0; i < n; i++) cin >> pre[i];
  for (int i = 0; i < n; i++)
    if (pre[i] == 0) con = 1;
  while (con) {
    for (int i = 0; i < n; i++)
      if (!pre[i]) {
        label = i;
        break;
      }
    unpresent[label] = 1;
    tot++;
    for (int i = 0; i < n; i++) {
      if (contact[label][i]) pre[i]--;
    }
    con = 0;
    for (int i = 0; i < n; i++)
      if (pre[i] == 0) con = 1;
  }
  cout << tot << endl;
  for (int i = 0; i < n; i++)
    if (unpresent[i]) cout << i + 1 << " ";
  return 0;
}
