#include <bits/stdc++.h>
using namespace std;
int n, c[155];
bool used[155];
string s[155];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int(i) = 0; (i) < (n); i++) cin >> s[i];
  bool flag = 0;
  for (int(i) = 0; (i) < (n); i++) {
    cin >> c[i];
    if (c[i] == 0) flag = 1;
  }
  if (!flag) {
    puts("0");
    return 0;
  }
  vector<int> ans;
  bool update = 0;
  while (true) {
    update = 0;
    for (int(i) = 0; (i) < (n); i++) {
      if (used[i]) continue;
      if (c[i] == 0) {
        used[i] = 1;
        ans.push_back(i);
        update = 1;
        for (int(j) = 0; (j) < (s[i].size()); j++) {
          if (used[j]) continue;
          c[j] -= s[i][j] - '0';
        }
      }
    }
    if (!update) break;
  }
  cout << ans.size() << '\n';
  for (int(i) = 0; (i) < (ans.size()); i++) {
    if (i) cout << " ";
    cout << ans[i] + 1;
  }
  cout << '\n';
  return 0;
}
