// Arup Guha
// 4/22/2021
// Solution to 2021 NADC Problem F: Investigating Imposters

import java.util.*;
import java.io.*;

public class f {
	
	public static ArrayList<Integer>[] g;
	public static boolean[][] implicate;

	public static void main(String[] args) throws Exception {
	
		// Get input.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		int n = Integer.parseInt(tok.nextToken());
		int k = Integer.parseInt(tok.nextToken());
		
		// Set up each list.
		g = new ArrayList[n];
		for (int i=0; i<n; i++) 
			g[i] = new ArrayList<Integer>();
			
		// Read the lists.
		for (int i=0; i<n; i++) {
			tok = new StringTokenizer(stdin.readLine());
			int num = Integer.parseInt(tok.nextToken());
			for (int j=0; j<num; j++)
				g[i].add(Integer.parseInt(tok.nextToken())-1);
		}
		
		// See how many people are forced to be truth tellers if person i is one.
		boolean[][] implicate = new boolean[n][];
		for (int i=0; i<n; i++) {
			implicate[i] = new boolean[n];
			dfs(i,implicate[i]);
		}
		
		// Ask if person i can be an imposter.
		for (int i=0; i<n; i++) {
		
			// I need n-k people except for i not to list i.
			int countNo = 0;
			for (int j=0; j<n; j++) {
				if (j == i) continue;
				if (!implicate[j][i])
					countNo++;
			}
			
			// Ta da!
			if (countNo >= n-k)
				System.out.println("0");
			else
				System.out.println("1");
		}
	}
	
	// Runs a dfs on v on the original graph.
	public static void dfs(int v, boolean[] used) {
		used[v] = true;
		for (Integer x: g[v])
			if (!used[x])
				dfs(x, used);
	}
}
	