#include <bits/stdc++.h>
using namespace std;
char p[101][101];
int a[101];
int ans[101];
vector<int> us;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) cin >> p[i][j];
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i)
    if (!a[i]) {
      us.push_back(i + 1);
      for (int j = 0; j < n; ++j) ans[j] += (p[i][j] == '1');
    }
  for (int i = 0; i < n; ++i)
    if (a[i] == ans[i]) {
      us.push_back(i + 1);
      for (int j = 0; j < n; ++j) ans[j] += (p[i][j] == '1');
      i = -1;
    }
  for (int i = 0; i < n; ++i)
    if (a[i] == ans[i]) cout << -1, exit(0);
  cout << us.size() << "\n";
  for (int i = 0; i < us.size(); ++i) cout << us[i] << ' ';
}
