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: dat = []
n = int(input())
for i in range(n):
    dat.append([0] * n)
for i in range(n):
    s = list(map(int, input().split()))
    for j in range(len(s) - 2):

        dat[i][s[j + 2] - 1] = 1
for i in range(n):
    l = list(map(str, dat[i]))
    print(" ".join(l))

Python: n = int(input())
adj_matrix = [[0 for _ in range(n)] for _ in range(n)]
    
for i in range(n):
    l = list(map(int, input().split()))[2:]
    for j in l:
        adj_matrix[i][j-1] = 1

for l in adj_matrix:
    print(*l)

Python: # coding: utf-8

n = int(input())
G = [[0]*n for i in range(n)]

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

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


# 入力: 隣接リストを与える
# 出力: 隣接行列を出力する

Python: n=int(input())
G=[[0 for i in range(n)]for j in range(n)]
u=[0 for i in range(n)]
for i in range(n):
    A=input().split()
    u[i]=int(A[0])
    k=int(A[1])
    for j in range(k):
        x=int(A[j+2])-1
        G[i][x]=1
for i in range(n):
    for j in range(n):
        if j<n-1:
            print(G[i][j],end=" ")
        else:
            print(G[i][j])

Python: N = int(input())
dp = [[0 for i in range(N)] for j in range(N)] 

for _ in range(N):
    inputs = list(map(int, input().split()))
    u = inputs[0]
    k = inputs[1]
    v = inputs[2:]
    #print(u, k, v)
    for each in v:
        dp[u-1][each-1] = 1

for i in range(N):
    print(*dp[i][:])

Python: import sys
n = int(input())
input_lines = [[int(i) for i in lines.split()] for lines in sys.stdin.read().splitlines()]
for i in range(n):
    out_list = ['0'] * n
    m = len(input_lines[i])
    for j in range(m-1, 1, -1):
        out_list[input_lines[i][j]-1] = '1'
    print(' '.join(out_list))

Python: n = int(input())
M = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    a,*b = map(int,input().split())
    a -= 1
    for i in b[1:]:
        M[a][i-1] = 1
for i in range(n):
    print(*M[i])

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

for i in range(n):
	a=list(map(int,input().split()))
	#print(a)
	if a[1]>0:
		for j in range(2,len(a)):
			list1[i][a[j]-1]=1
			
for i in range(n):
	print(*list1[i])

Python: # ??\???????????????
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]

# N*N?????£??\??????????????°?????????
graph_table = [[0]*n for i in range(n)]

# ??£??\??????????????£??\???????????????
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

print(graph_table)

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

Python: def print_list(a):
    for x in a[:-1]:
        print(x, end=" ")
    print(a[-1])


def print_mat(a):
    for i in range(len(a)):
        print_list(a[i])


n = int(input())
adj = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    s = [int(x) for x in input().split()]
    u = s[0]
    for v in s[2:]:
        adj[u - 1][v - 1] = 1


print_mat(adj)

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

Python: n = int(input())

A = [[0]*n for _ in range(n)]

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

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

Python: g = int(input())
v = [[0] * g for _ in range(g)]
for i in range(g):
    inp = list(map(int, input().split()))
    for j in range(inp[1]):
        v[inp[0]-1][inp[2+j]-1] = 1
for row in range(g):
    for col in range(g):
        if col == g-1:
            print(v[row][col], end="")
        else:
            print(v[row][col], end=" ")
    print()

Python: import sys
data_list = []
for line in sys.stdin:
	data_list.append(line.split())

class Node():
    def __init__(self, name, transaction_list = None):
        self.transaction_list = transaction_list or []

    def add_node(self, node):
        self.transaction_list.append(node)

def convert_adjencentList_to_adjencentMatrix(adjencentList):
    adjencent_matrix = [[0 for i in range(len(adjencentList))] for j in range(len(adjencentList))]
    count = 0
    for targetList in adjencentList:
        targetList.transaction_list.sort()
        for target_index in targetList.transaction_list :
            adjencent_matrix[count][int(target_index) - 1] = 1
        count = count + 1

    for i in adjencent_matrix:
        print(*i)

if __name__ == "__main__":
        node_data_list = []

        for node_data in data_list[1:]:
            node = Node(node_data[1])
            for transaction_node in node_data[2:]:
                node.add_node(transaction_node)

            node_data_list.append(node)

        convert_adjencentList_to_adjencentMatrix(node_data_list)

Python: n=int(input())
G=[[0 for i in range(n+1)] for i in range(n+1)]
for i in range(n):
    arr=[int(x) for x in input().split()[2:]]
    for j in arr:
        
        G[i+1][j]=1
        
for k in range(1,n+1):
    G[k].pop(0)
    print(' '.join(map(str, G[k])))

Python: n = int(input())
list_m = [[0] * n for i in range(n)]
for i in range(n):
	a,b, *args = map(int,input().split())
	for num in args:
		list_m[a-1][num-1] = 1
for i in range(n):
	for j in range(n):
		list_m[i][j] = str(list_m[i][j])
for row in list_m:
	print(" ".join(row))