#include <bits/stdc++.h>
using namespace std;
int n;
int a[102][102];
int given[102];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char ch;
      cin >> ch;
      a[i][j] = ch - '0';
    }
  }
  bool iszero = false;
  for (int i = 0; i < n; i++) {
    cin >> given[i];
    if (given[i] == 0) iszero = true;
  }
  if (iszero == false) {
    cout << 0 << '\n';
    return 0;
  }
  set<int> s;
  for (int i = 0; i < n; i++) {
    bool ok = false;
    for (int j = 0; j < n; j++) {
      if (given[j] == 0) {
        s.insert(j);
        ok = true;
        for (int k = 0; k < n; k++)
          if (a[j][k] == 1) given[k]--;
      }
    }
    if (!ok) break;
  }
  cout << s.size() << '\n';
  ;
  for (auto it = s.begin(); it != s.end(); it++) cout << (*it + 1) << ' ';
  cout << '\n';
  return 0;
}
