#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int n;
char a[101][101];
int d[101];
void solve() {
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  exit(0);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  for (int i = 1; i <= n; i++) cin >> d[i];
  for (int j = 1; j <= n; j++) {
    int f = 0;
    for (int i = 1; i <= n; i++)
      if (d[i] == 0) f = i;
    if (f == 0) solve();
    for (int i = 1; i <= n; i++)
      if (a[f][i] == '1') d[i]--;
    ans.push_back(f);
  }
  solve();
}
