#include <bits/stdc++.h>
using namespace std;
string st;
int ar[200][200];
int n;
int need[200], have[200], used[200];
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> st;
    for (int j = 0; j < st.size(); j++) ar[i][j + 1] = st[j] - 48;
  }
  for (int i = 1; i <= n; i++) cin >> need[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) have[j] += ar[i][j];
  while (true) {
    int found = -1;
    for (int i = 1; i <= n; i++)
      if (have[i] == need[i]) found = i;
    if (found == -1) break;
    used[found] = 1;
    for (int i = 1; i <= n; i++) have[i] -= ar[found][i];
  }
  for (int i = 1; i <= n; i++)
    if (used[i] == 0) ans.push_back(i);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
