#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100 + 10;
int n, in[Maxn], num[Maxn];
bool arr[Maxn][Maxn], mark[Maxn];
int main() {
  char a;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> a;
      if (a == '1') {
        arr[i][j] = 1;
        num[j]++;
      }
    }
  for (int i = 0; i < n; i++) cin >> in[i];
  bool ok = false;
  while (!ok) {
    int j = 0;
    while (j < n && (mark[j] == true || (mark[j] == false && num[j] != in[j])))
      j++;
    if (j == n)
      ok = true;
    else {
      mark[j] = true;
      for (int i = 0; i < n; i++)
        if (arr[j][i] == 1) num[i]--;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (!mark[i]) ans++;
  cout << ans << endl;
  for (int i = 0; i < n; i++)
    if (!mark[i]) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
