Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

Python: def main():
    n = int(input())
    rows = []
    for i in range(n):
        rows.append([int(x) for x in input().split()])
    for row in rows:
        u,k = row[0],row[1]
        ul = [0]*n
        for j in range(k):
            ul[row[j+2]-1] = 1
        print(' '.join([str(u) for u in ul]))

if __name__ == '__main__':
    main()

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

Python: n=int(input())

arr = [[0 for i in range(n)] for j in range(n)]

for i in range(0,n):
    l=raw_input().split()
    if(int(l[1])>=1):
        x=int(l[0])
        y=int(l[1])
        p=len(l)
        d=0
        while(2+d<p):
            z=int(l[2+d])
            arr[x-1][z-1]=1
            d=d+1

print(arr)

Python: class Node:
    def __init__(self, num, deg, neib):
        self.num = num
        self.deg = deg
        self.neib = neib


dnum = int(input())
N = []
for i in range(dnum):
    data = input().split()
    
    u = int(data[0])
    k = int(data[1])
    if k > 0:
        v = list(map(int, data[2:]))
        node = Node(u,k,v)
    else:
        node = Node(u,k,0)

    N.append(node)

O = []
for e in N:
    out = [0]*dnum
    if e.neib != 0:
        for j in e.neib:
            out[j-1] = 1
    else: pass

    O.append(out)

for i in O:
    print(*i)

Python: import sys


class Graph:
    def __init__(self, nodes={}):
        self.nodes = nodes


n = int(input())
G = Graph()
for line in sys.stdin:
    numList = line.split()
    G.nodes[numList[1]] = numList[1:]

for _ in range(n):
    out = ''
    for i in range(n):
        if i + 1 != n:
            out += '0 ' if i + 1 in G.nodes[1] else '1 '
        else:
            out += '0' if i + 1 in G.nodes[1] else '1'
    print(out)

Python: N = int(input())
ans = []
for i in range(N):
    a = list(map(int, input().split()))
    pre = [0 for _ in range(N)]
    for k in a[2:]:
        pre[k-1] = 1
    ans.append(pre)
for i in range(N):
    print(' '.join(list(map(str, ans[i]))))

Python: n=int(input())
da=[[0 for i in range(n)] for i in range(n)]
for i in range(n):
    se=list(map(int,input().split()))
    for j in se[2:]:
        da[i][j-1]=1
for i in range(n):
    for j in range(n):
        if j==n-1:
            print(da[i][j])
        else:
            print(da[i][j],end=' ')

Python: n = int(input())

adj_mat = [[0 for i in range(n + 1)] for j in range(n)]

for i in range(n):
    adj_list_i = list(map(int, input().split()[2:]))
    for j in adj_list_i:
        adj_mat[i][j] = 1

for r in adj_mat:
    print(*r[1:])

Python: n = int(input())

A = [ [] for i in range(n)]

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

B = [[ 0 for i in range(n)] for j in range(n)]

for i in range(n):
  a = A[i][0]
  j = A[i][1]
  if j != 0:
    for k in range(j):
      b = A[i][k+2]
      B[a-1][b-1] = 1

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

Python: import sys
def main():
    n = int(input())
    lines = sys.stdin.readlines()
    outputs = [None] * n
    str_range = [str(i) for i in range(1, n+1)]
    for i in range(n):
        idx, idx_n, *idx_vertices = lines[i].rstrip().split()
        outputs[i] = ['1' if str_i in idx_vertices else '0' for str_i in str_range]

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


main()

Python: n = int(input())
for _ in range(n):
    v = list(map(int, input().split()))[2:]
    line = [0] * n
    for i in v:
        line[i - 1] = 1
    print(*line)

Python: N = int(input())
A = [[0]*N for _ in range(N)]

for _ in range(N):
    l = list(map(int, input().split()))
    u, k = l.pop(0), l.pop(0)
    
    row = A[u-1]
    for x in l:
        row[x-1] = 1

for row in A:
    print(*row)

Python: n = int(input())
ans = list()
for i in range(n):
    tmp = list()
    for j in range(n):
        tmp.append(0)
    ans.append(tmp)

for i in range(n):
    l = [int(i) for i in input().split()]
    for li in l[2:]:
        # print(i, li)
        ans[i][li - 1] = 1

for i in ans:
    print(" ".join([str(x) for x in i]))

Python: 
"""
Main??????????????????
"""
# Node??°?????????
N = int(input())

# Node??????????????????????????????
nodes = [[0 for i in range(N)] for j in range(N)]

# Node??????????¨????
for i in range(N):
    j = list(map(int, input().split())) # ??\??????????§£
    no = j[0] - 1                       # Node???????????????
    childNos = j[2:]                    # ??????????´??????????

    for j in range(len(childNos)):
        childNo = childNos[j] - 1
        nodes[no][childNo] = 1


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

Python: n=int(input())

a=[[0 for i in range(n)]for j in range(n)]

for i in range(n):
    p=[int(x) for x in input().split()]
    for j in range(n):
        if j+1 in p[2:]:
            a[i][j]=1
for i in range(n):
    for j in range(n):
        print(a[i][j],"",end="")
    print("")

Python: n = int(input())

for i in range(n):
    ans = [0] * n
    tmp = list(map(int, input().split()))
    u, k, v = tmp[0], tmp[1], tmp[2:]
    for j in v:
        ans[j-1] = 1
    print(' '.join(map(str, ans)))

Python: import numpy as np
n=int(input())
ls=np.zeros((n,n))
for i in range(n):
	tmp=input().split()
	for j in range(int(tmp[1])):
		ls[i][int(tmp[j+2])-1]=1

for i in range(n):
    for j in range(n):
        if(j!=n-1):
            print(int(ls[i][j]), end=' ')
        else:
            print(int(ls[i][j]))

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

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

    for j in inta[2:2+inta[1]]:
        ans[inta[0]-1][j-1] = 1

for i in ans:
    print(" ".join(map(str,i)))