#include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
  char c = getchar();
  long long num;
  bool sign = false;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = true;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return sign ? -num : num;
}
char X[105][105];
int G[105][105];
int A[200];
vector<int> V;
int main() {
  int n = getnum();
  for (int i = 1; i <= n; i++) gets(X[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) G[i][j] = X[i][j] - '0';
  for (int i = 1; i <= n; i++) A[i] = getnum();
  for (int i = 1; i <= n; i++) {
    if (A[i] == 0) {
      for (int j = 1; j <= n; j++) A[j] -= G[i][j];
      V.push_back(i);
      i = 0;
    }
  }
  for (int i = 1; i <= n; i++)
    if (A[i] == 0) {
      puts("-1");
      return 0;
    }
  printf("%d\n", V.size());
  for (int i = 0; i < V.size(); i++) printf("%d ", V[i]);
}
