#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, f, arr[102], tmp[102], pre[102], ans = 0;
  vector<int> v;
  char s[102][102];
  cin >> n;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) cin >> arr[i];
  memset(tmp, 0, sizeof(tmp));
  memset(pre, 0, sizeof(pre));
  v.clear();
  while (true) {
    f = -1;
    for (i = 0; i < n; i++) {
      if (tmp[i] == arr[i]) {
        f = i;
        break;
      }
    }
    if (f == -1) break;
    if (pre[f]) {
      printf("-1");
      return 0;
    }
    v.push_back(f);
    for (i = 0; i < n; i++) {
      if (s[f][i] == '1') tmp[i]++;
    }
    ans++;
    pre[f] = 1;
  }
  printf("%d\n", ans);
  for (i = 0; i < v.size(); i++) cout << v[i] + 1 << " ";
  return 0;
}
