#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int n, k;
int mas[N];
int ma[N][N];
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  string st;
  for (int i = 0; i < n; ++i) {
    cin >> st;
    for (int j = 0; j < n; ++j) ma[i][j] = (st[j] == '1');
  }
  for (int j = 0; j < n; ++j) cin >> mas[j];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!mas[j]) {
        for (int k = 0; k < n; ++k) {
          if (ma[j][k]) mas[k]--;
        }
        ans.push_back(j);
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] + 1 << ' ';
}
