#include <bits/stdc++.h>
using namespace std;
const int N = 101;
char a[N][N];
int b[N];
int c[N];
bool mark[N];
int n, nres;
int main() {
  int i, j;
  bool flag;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) cin >> b[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) c[j] += a[i][j] == '1';
  while (1) {
    flag = true;
    for (j = 0; j < n; j++)
      if (c[j] == b[j] && !mark[j]) {
        mark[j] = true;
        flag = false;
        for (i = 0; i < n; i++)
          if (a[j][i] == '1') c[i]--;
        break;
      }
    if (flag) break;
  }
  for (i = 0; i < n; i++)
    if (!mark[i]) nres++;
  if (nres) {
    cout << nres << endl;
    for (i = 0; i < n; i++)
      if (!mark[i]) cout << i + 1 << ' ';
    cout << endl;
  } else {
    flag = false;
    for (i = 0; i < n; i++)
      if (b[i] == 0) flag = true;
    if (flag)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
