#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
char s[110][110];
int a[110];
vector<int> ans;
int n;
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);
  for (int i = 0; i < n; i++) {
    int t = -1;
    for (int j = 0; j < n; j++)
      if (a[j] == 0) {
        t = j;
        break;
      }
    if (t == -1) break;
    ans.push_back(t);
    for (int j = 0; j < n; j++) a[j] -= s[t][j] - '0';
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i] + 1);
}
