Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

Python: from sys import stdin
n = int(stdin.readline())
v = [[0] * (n + 1) for i in range(n + 1)]
for u in range(1, n + 1):
    U = [int(j) for j in stdin.readline().split()]
    for k in U[2:]:
        v[u][k] += 1
for i in range(1, n + 1):
    print(*v[i][1:])

Python: n = int(input())
Adj = [[0 for i in range(n)] for i in range(n)]

for i in range(n):
    u = list(map(int, input().split()))
    if u[1] > 0:
        for i in u[2: 2 + u[1]]:
            Adj[u[0] - 1][i - 1] = 1

for i in range(n):
    print(" ".join(map(str, Adj[i])))

Python: n = int(input())
adj_list = [ [0]*n for _ in range(n) ]

for _ in range(n):
    lst = list(map(int, input().split()))
    
    x = lst[0] - 1
    
    if lst[1] == 0:
        continue
    
    for y in lst[2:]:
        adj_list[x][y-1] = 1
    
for r in adj_list:
    print(" ".join([ str(v) for v in r]))

Python: #!/usr/bin/python3
n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    u = l[0]
    V = l[2:]
    for v in V:
        A[u - 1][v - 1] = 1
for a in A:
    print(" ".join(map(str, a)))

Python: n = int(input())
in_list = []
for i in range(n):
    in_list.append(list(map(int, input().split())))

matrices = [["0" for _ in range(n)] for _ in range(n)]

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = "1"

for i in range(n):
    print(" ".join(matrices[i]))

Python: n = int(input())
m = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
  u, k, *v = map(int, input().split())
  for j in v:
    m[u-1][j-1] = 1
for i in range(n):
  print(" ".join(map(str,m[i])))

Python: # -*- coding: utf-8 -*-

N = int(input())
adj = [["0"]*N for _ in range(N)]

for _ in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = "1"

for a in adj:
    print(" ".join(a))

Python: #!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n=int(input())
G=[[0]*n for i in range(n)]
for i in range(n):
    inp=tuple(map(int,input().split()))
    now=inp[0]
    for j in range(2,inp[1]+2):
        G[now-1][inp[j]-1]=1
for g in G:
    print(*g)

Python: n=int(input())
adj=[list(map(int,input().split())) for _ in range(n)]

lst=[[0 for i in range(n)] for j in range(n)]
for x in adj:
    u,v=x[0],x[2:]
    for y in v:
        lst[u-1][y-1]=1

for x in lst:
    print(" ".join(map(str,x)))

Python: N= int(input())

b=[[0 for i in range(N)]for j in range(N)]


for i in range(N):
    a= list(map(int, input().split()))
    for j in range(a[1]):
        b[i][a[2+j]-1]=1
    
for i in range(N):
    print(*b[i])

Python: n=int(input())
G=[[0 for i in range(n)] for j in range(n)]

for i in range(n):
    u=list(map(int,input().split()))

    for j in range(2,len(u)):
        G[i][u[j]-1]=1


G=[' '.join(map(str,G[i])) for i in range(n)]
print('\n'.join(G))

Python: n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l1 = list( [0 for i in range(n)] for _ in range(n))
for i in l:
  a,b,*c = i
  for j in c:
    l1[a-1][j-1] = 1
for k in l1:
  print(*k)

Python: if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for _ in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????????
    graph_table = [[0]*num for _ in range(num)]
    for d in data:
        node_id = d[0]
        num_of_e = d[1]
        for e in d[2:]:
            graph_table[node_id-1][e-1] = 1

    # ???????????????
    for row in graph_table:
        print(*row)

Python: n = int(input())

m = [[0 for _ in range(n)] for _ in range(n)]

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    u = tmp[0]
    k = tmp[1]
    l = tmp[2:]
    for x in l:
        m[u-1][x-1] = 1

for i in range(n):
    print(' '.join(map(str,m[i])))

Python: n=int(input())
ans=[[0]*n for _ in range(n)]
for _ in range(n):
    u,k,*V=map(int,input().split())
    for v in V:
        ans[u-1][v-1]=1
for i in range(n):
    print(*ans[i])

Python: N = int(input())
P = [[0 for _ in range(N)] for _ in range(N)] 
for i in range(N):
    u,k,*varray = map(int,input().split()) # u,k は数, varray は配列
    for v in varray:
        P[u-1][v-1] = 1
for j in P:
    print(" ".join(map(str,j)))

Python: n = int(input())
adj = []
# adj = [[None] * n for _ in range(n)]
ans = [[0] * n for _ in range(n)]

for i in range(n):
    temp = list(map(int, input().split()))
    if len(temp) > 2:
        adj.append(temp[2:])
    else:
        adj.append([])

# print(adj)
# print(ans)

for i in range(n):
    for j in range(len(adj[i])):
        ans[i][adj[i][j]-1] = 1

# print(ans)

for i in range(n):
    print(*ans[i])

Python: # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A&lang=jp
# Graph: python3
#  2018.12.04 yonezawa

import sys
input = sys.stdin.readline
#import cProfile
def main():
    n = int(input())
    nmap = [[0 for i in range(n)] for i in range(n)]

    for _ in range(n):
        l = list(map(int,input().split()))
        a = l[0] - 1
        for i in l[2:]:
            nmap[a][i-1] = 1
    for i in nmap:
        print (*i)
        
if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()

Python: 
N = int(input())

# initialize
ans = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
    a = list(map(int, input().split()))
    id = a[0]
    jisu = a[1]
    for j in range(jisu):
        c = a[j+2]
        ans[i][c-1] = 1

for i in range(N):
    for j in range(N):
        if j != N-1:
            print(ans[i][j], end=" ")
        else:
            print(ans[i][j], end="")

            if i != N-1: print("")