#include <bits/stdc++.h>
using namespace std;
char str[110][110];
int temp[110];
int num[110];
int main() {
  int n;
  while (cin >> n) {
    bool flag = true;
    int pos;
    memset(num, 0, sizeof(num));
    for (int i = 1; i <= n; ++i) {
      cin >> (str[i] + 1);
    }
    for (int i = 1; i <= n; ++i) {
      cin >> temp[i];
      if (temp[i] == 0) {
        flag = false;
        pos = i;
      }
    }
    if (flag) {
      cout << 0 << endl;
    } else {
      queue<int> q;
      q.push(pos);
      set<int> s;
      while (!q.empty()) {
        int now = q.front();
        q.pop();
        if (num[now] == temp[now]) {
          s.insert(now);
          for (int i = 1; i <= n; ++i) {
            if (str[now][i] == '1') {
              ++num[i];
            }
            if (num[i] == temp[i]) {
              q.push(i);
            }
          }
        }
        if (q.empty()) {
          bool vis = true;
          for (int i = 1; i <= n; ++i) {
            if (num[i] == temp[i]) {
              q.push(i);
              vis = false;
              break;
            }
          }
          if (vis) {
            break;
          }
        }
      }
      cout << s.size() << endl;
      for (auto it : s) {
        cout << it << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
