#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:250000000")
using namespace std;
long long n, k, res = 0;
string s[109];
int a[109], sms[109], result[109];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int t = 0; t < n; ++t) {
    for (int i = 0; i < n; ++i) {
      if (a[i] == sms[i]) {
        result[i] = 1;
        res++;
        for (int j = 0; j < n; ++j) {
          if (s[i][j] == '1') {
            sms[j]++;
          }
        }
      }
    }
  }
  cout << res << endl;
  for (int i = 0; i < n; ++i) {
    if (result[i] == 1) {
      cout << i + 1 << " ";
    }
  }
  return 0;
}
