#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> result;
bool grid[110][110];
int myarr[110];
char temp_c;
void process(int x) {
  result.push_back(x);
  for (int i = 0; i < n; i++) {
    if (grid[x][i]) {
      myarr[i]--;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> temp_c;
      if (temp_c == '1') {
        grid[i][j] = true;
      } else
        grid[i][j] = false;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> myarr[i];
  }
  while (true) {
    bool good = true;
    for (int i = 0; i < n; i++) {
      if (myarr[i] == 0) {
        good = false;
        process(i);
        break;
      }
    }
    if (good) break;
  }
  sort(result.begin(), result.end());
  cout << result.size() << endl;
  for (int i = 0; i < result.size(); i++) {
    if (i > 0) cout << " ";
    cout << result[i] + 1;
  }
  cout << endl;
  return 0;
}
