#include <bits/stdc++.h>
using std::max;
using std::memset;
using std::min;
using std::swap;
using std::vector;
const int maxn = 105;
int n, a[maxn], b[maxn];
vector<int> e[maxn];
vector<int> vis;
bool sol;
char line[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", line + 1);
    for (int j = 1; j <= n; ++j)
      if (line[j] == '1') e[i].push_back(j);
  }
  sol = true;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == 0) sol = false;
  }
  if (sol) {
    puts("0");
    return 0;
  }
  while (1) {
    sol = true;
    for (int i = 1; i <= n; ++i)
      if (a[i] == 0) {
        for (auto y : e[i])
          if (a[y] > 0) a[y]--;
        a[i] = 2333;
        vis.push_back(i);
      }
    for (int i = 1; i <= n; ++i)
      if (a[i] == 0) sol = false;
    if (sol) break;
  }
  printf("%d\n", vis.size());
  for (auto p : vis) printf("%d ", p);
  return 0;
}
