#include <bits/stdc++.h>
using namespace std;
const int N = 123;
char g[N][N];
int d[N], a[N];
queue<int> q;
vector<int> ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> g[i][j];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    if (!a[i]) q.push(i);
  while (!q.empty()) {
    int cur = q.front();
    for (int i = 0; i < n; i++)
      if (g[cur][i] == '1') {
        d[i]++;
        if (a[i] == d[i]) q.push(i);
      }
    ans.push_back(cur);
    q.pop();
  }
  cout << ((int)(ans).size()) << '\n';
  for (int i = 0; i < ((int)(ans).size()); i++) cout << ans[i] + 1 << ' ';
  cout << '\n';
  return 0;
}
