#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 1010;
int n;
bool call[105][105];
int guess[105];
int cur[105];
int part_num;
bool part[105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  part_num = n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') {
        call[i][j] = true;
        cur[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> guess[i];
    part[i] = true;
  }
  while (true) {
    bool is_done = true;
    for (int i = 0; i < n; i++) {
      if (guess[i] == cur[i]) {
        part[i] = false;
        is_done = false;
        part_num--;
        for (int j = 0; j < n; j++) {
          if (call[i][j]) cur[j]--;
        }
      }
    }
    if (is_done) break;
  }
  cout << part_num << endl;
  for (int i = 0; i < n; i++)
    if (part[i]) cout << i + 1 << " ";
  return 0;
}
