#include <bits/stdc++.h>
using namespace std;
int n;
int cnt = 0;
int ans[105] = {0};
int num[104];
int to[105][105];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%1d", &to[i][j]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &num[i]);
  }
  int flag = 0;
  int t = 0;
  while (1) {
    ++t;
    flag = 0;
    for (int i = 1; i <= n; ++i) {
      if (num[i] == 0 && ans[i] == 0) {
        ans[i] = 1;
        cnt++;
        for (int j = 1; j <= n; ++j) {
          if (to[i][j] == 1) num[j]--;
        }
        flag = 1;
        break;
      }
    }
    if (flag == 0) break;
    if (t > n) {
      printf("-1");
      return 0;
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; ++i) {
    if (ans[i] == 1) {
      printf("%d ", i);
    }
  }
}
