#include <bits/stdc++.h>
using namespace std;
int n;
char S[110][110];
int A[100];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%s", S[i]);
  for (int i = 0; i < n; ++i) scanf("%d", A + i);
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (A[j] == 0) {
        for (int k = 0; k < n; ++k) {
          if (S[j][k] == '1') A[k] -= 1;
        }
        ans.push_back(j + 1);
      }
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d ", ans[i]);
  }
}
