#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 19;
char s[N][N];
int A[N], B[N], n;
vector<int> V;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i < n + 1; i++) scanf("%d", &A[i]);
  for (;;) {
    int x = -1;
    for (int i = 1; i < n + 1; i++)
      if (A[i] == B[i]) {
        x = i;
        break;
      }
    if (x == -1) break;
    for (int i = 1; i < n + 1; i++)
      if (s[x][i] == '1') B[i]++;
    V.push_back(x);
  }
  printf("%d\n", V.size());
  for (int i = 0; i < V.size(); i++) printf("%d ", V[i]);
}
