#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[1000010];
  scanf("%s", ch);
  return ch;
}
const int MAX_LG = 40;
const long long maxn = 500 + 100;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e9 + 100;
long long a[maxn][maxn], b[maxn];
long long friends[maxn];
bool ok[maxn];
vector<long long> vc;
long long n;
inline void solve(long long rem) {
  if (!rem) return;
  for (long long i = 0; i < n; i++) {
    if (ok[i]) continue;
    if (friends[i] == b[i]) {
      ok[i] = true;
      for (long long pt = 0; pt < n; pt++)
        if (a[i][pt]) friends[pt]--;
      solve(rem - 1);
      return;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (ok[i]) continue;
    vc.push_back(i + 1);
  }
}
int32_t main() {
  n = in();
  for (long long i = 0; i < n; i++) {
    string s = get();
    for (long long j = 0; j < n; j++)
      a[i][j] = s[j] - '0', friends[j] += s[j] - '0';
  }
  for (long long i = 0; i < n; i++) b[i] = in();
  solve(n);
  cout << vc.size() << "\n";
  for (auto v : vc) cout << v << " ";
}
