#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
int a[N][N], b[N];
int sel[N];
int n;
int dfs() {
  int col = -1;
  for (int i = 0; i < n; ++i) {
    if (!b[i]) {
      col = i;
      break;
    }
  }
  if (col == -1) {
    return 1;
  }
  int i = col;
  for (int j = 0; j < n; ++j) {
    b[j] -= a[i][j];
  }
  sel[i] = 1;
  dfs();
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    static char s[N];
    scanf("%s", s);
    for (int j = 0; j < n; ++j) {
      a[i][j] = s[j] == '1';
    }
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  if (dfs()) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += sel[i];
    }
    cout << cnt << endl;
    for (int i = 0; i < n; ++i) {
      if (sel[i]) {
        cout << i + 1 << ' ';
      }
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
