import java.util.*;

public class InvestigatingImposters_AN {
  static boolean[][] tc = new boolean[512][512];
  static int[][] adj = new int[512][512];

  private static void dfs(int s, int v) {
    tc[s][v] = true;

    for (int i = 1; i <= adj[v][0]; i++) {
      if (!tc[s][adj[v][i]]) dfs(s, adj[v][i]);
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(), k = s.nextInt();
    for (int i = 0; i < n; i++) {
      int len = s.nextInt();
      for (int j = 0; j < len; j++) {
        int source = s.nextInt() - 1;
        adj[source][++adj[source][0]] = i;
      }
    }

    for (int i = 0; i < n; i++) dfs(i, i);

    for (int i = 0; i < n; i++) {
      int count = 0;
      for (int j = 0; j < n; j++) if (i != j && tc[i][j]) count++;
      System.out.println(count < k ? 0 : 1);
    }
  }
}
