#include <bits/stdc++.h>
using namespace std;
string s[111];
int n, a[111];
vector<int> ans;
void f(int x) {
  ans.push_back(x + 1);
  for (int i = 0; i < n; i++)
    if (s[x][i] == '1') a[i]--;
}
bool ok;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> a[i];
  while (!ok) {
    ok = 1;
    for (int i = 0; i < n; i++)
      if (a[i] == 0) {
        ok = 0;
        f(i);
        break;
      }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (size_t i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
