#include <bits/stdc++.h>
using namespace std;
int n;
char s[110][110];
int c[110], now[110];
int g[110];
bool b[110];
int ans = 0;
int main() {
  scanf("%d", &n);
  getchar();
  for (int i = 1; i <= n; i++) {
    cin.getline(s[i], 110);
    for (int j = 0; j < n; j++)
      if (s[i][j] == '1') c[j + 1]++;
  }
  for (int i = 1; i <= n; i++) {
    cin >> g[i];
  }
  int i = 0;
  memset(now, 0, sizeof(now));
  while (i < n) {
    i++;
    if (!b[i] && now[i] == g[i]) {
      b[i] = 1;
      for (int j = 0; j <= n - 1; j++)
        if (s[i][j] == '1') now[j + 1]++;
      ans++;
      i = 0;
    }
  }
  for (int i = 1; i <= n; i++)
    if (now[i] == g[i]) {
      cout << "-1";
      return 0;
    }
  cout << ans << endl;
  for (int i = 1; i <= n; i++)
    if (b[i]) cout << i << " ";
  return 0;
}
