#include <bits/stdc++.h>
using namespace std;
int n;
int ju[105][105];
int ans[105] = {0}, top = 0;
int a[105];
bool vis[105] = {0};
int main() {
  cin >> n;
  char s[105];
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) {
      ju[i][j] = s[j] - '0';
    }
  }
  bool flag = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  while (flag) {
    flag = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 0) {
        ans[++top] = i;
        for (int j = 1; j <= n; j++) {
          a[j] -= ju[i][j];
        }
        flag = 1;
      }
    }
  }
  cout << top << endl;
  for (int i = 1; i <= top; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
