#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int maxn = 1111111;
const int INF = 1 << 26;
const int logN = 18;
int n;
char g[111][111];
int a[111];
int cnt[111];
int vis[111];
void upd(int x) {
  for (int(i) = 0; i < (int)(n); ++(i))
    if (g[x][i] == '1') cnt[i]++;
}
int main(int argc, char const *argv[]) {
  scanf("%d", &(n));
  for (int(i) = 0; i < (int)(n); ++(i)) scanf("%s", (g[i]));
  for (int(i) = 0; i < (int)(n); ++(i)) scanf("%d", &(a[i]));
  queue<int> q;
  for (int(i) = 0; i < (int)(n); ++(i))
    if (a[i] == 0) {
      q.push(i);
    }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    upd(x);
    for (int i = 0; i < n; ++i)
      if (cnt[i] == a[i]) q.push(i);
  }
  for (int(i) = 0; i < (int)(n); ++(i))
    if (cnt[i] == a[i]) {
      puts("-1");
      return 0;
    }
  vector<int> ans;
  for (int(i) = 0; i < (int)(n); ++(i))
    if (vis[i]) ans.push_back(i + 1);
  printf("%d\n", (ans.size()));
  for (int(i) = 0; i < (int)(ans.size()); ++(i))
    printf("%d%c", ans[i], " \n"[i == ans.size() - 1]);
}
