#include <functional>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, K, S, x;
  while (cin >> N >> K) {
    vector<vector<int>> v(N+1);
    for (int i = 1; i <= N; i++) {
      cin >> S;
      for (int j = 0; j < S; j++) {
        cin >> x;
        v[x].push_back(i);
      }
    }
    for (int i = 1; i <= N; i++) {
      vector<int> seen(N+1);
      int nseen = 0;
      function<void(int)> doit = [&] (int x) {
        if (seen[x]) return;
        seen[x] = true;
        nseen++;
        for (auto y : v[x]) doit(y);
      };
      doit(i);
      cout << (nseen > K) << endl;
    }
  }
}
