#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-5;
const int INF = 1000 * 1000 * 1000 + 1;
const long long LINF = (long long)1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long N = 1001;
void solve() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> c(n);
  for (int i = 0; i < n; ++i) cin >> c[i];
  vector<int> s(n, 0);
  vector<int> used(n, 0);
  int res = 0;
  bool ok = false;
  while (!ok) {
    ok = true;
    for (int i = 0; i < n; ++i) {
      if (s[i] == c[i]) {
        ++res;
        for (int j = 0; j < n; ++j) s[j] += (a[i][j] - '0');
        used[i] = 1;
        ok = false;
      }
    }
  }
  cout << res << endl;
  for (int i = 0; i < used.size(); ++i) {
    if (used[i]) cout << i + 1 << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  solve();
  return 0;
}
