#include <bits/stdc++.h>
using namespace std;
long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1ll;
  long long _tmp = mypow(_a, _x / 2, _mod);
  _tmp = (_tmp * _tmp) % _mod;
  if (_x & 1) _tmp = (_tmp * _a) % _mod;
  return _tmp;
}
bool equal(double _x, double _y) { return _x > _y - 1e-11 && _x < _y + 1e-11; }
int __ = 1, cs;
int n;
char c[110][110];
int v[110], nv[110];
int tk[110];
void build() {}
void init() {
  n = getint();
  for (int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (int i = 1; i <= n; i++) v[i] = getint();
  for (int i = 1; i <= n; i++) {
    tk[i] = 1;
    for (int j = 1; j <= n; j++) nv[j] += (c[i][j] == '1');
  }
}
void RM(int idx) {
  tk[idx] = 0;
  for (int j = 1; j <= n; j++) nv[j] -= (c[idx][j] == '1');
}
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (v[j] == nv[j]) {
        RM(j);
        break;
      }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (tk[i]) ans++;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (tk[i]) printf("%d ", i);
  puts("");
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
