#include <bits/stdc++.h>
using namespace std;
int a[105][105];
char b[105][105];
int ans[105];
int main() {
  int n, m;
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) scanf("%s", &b[i][1]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) a[i][j] = b[i][j] - '0';
  for (i = 1; i <= n; i++) scanf("%d", &ans[i]);
  vector<int> sol;
  while (1) {
    int found = 0;
    for (i = 1; i <= n; i++)
      if (ans[i] == 0) {
        found = i;
        break;
      }
    if (found == 0) break;
    for (j = 1; j <= n; j++) ans[j] -= a[found][j];
    sol.push_back(found);
  }
  printf("%d\n", sol.size());
  for (i = 0; i < sol.size(); i++) printf("%d ", sol[i]);
}
