#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n;
char s[105][105];
int a[105];
void dfs(int x) {
  if (x == n + 1) return;
  bool flag = true;
  for (int i = 1; i <= n; ++i)
    if (a[i] == 0) flag = false;
  if (flag) return;
  int pos;
  for (int i = 1; i <= n; ++i)
    if (a[i] == 0) pos = i;
  v.push_back(pos);
  for (int i = 1; i <= n; ++i)
    if (s[pos][i] == '1') a[i]--;
  dfs(x + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  dfs(1);
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); ++i) printf("%d ", v[i]);
  return 0;
}
