#include <bits/stdc++.h>
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1070000000LL;
const long long MOD = 1000000007LL;
using namespace std;
int n;
int m[111][111];
int a[111];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = (long long)(0); i < (long long)(n); i++)
    for (long long j = (long long)(0); j < (long long)(n); j++) {
      char c;
      cin >> c;
      m[i][j] = c - '0';
    }
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> a[i];
  vector<long long> ans;
  while (1) {
    int ng = -1;
    for (long long i = (long long)(0); i < (long long)(n); i++)
      if (a[i] == 0) {
        ng = i;
      }
    if (ng == -1) break;
    ans.push_back(ng + 1);
    for (long long i = (long long)(0); i < (long long)(n); i++) {
      a[i] -= m[ng][i];
    }
  }
  cout << ((long long)(ans).size()) << endl;
  for (int x : ans) cout << x << " ";
}
