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: if __name__ == "__main__":
    num_vertices = int(input())
    adj_matrix = [[0] * num_vertices for i in range(num_vertices)]

    for _ in range(num_vertices):
        vertex, _, *adjs = map(lambda x: int(x), input().split())
        for adj in adjs:
            adj_matrix[vertex -1][adj - 1] = 1

    for row in adj_matrix:
        print(" ".join([str(elem) for elem in row]))

Python: import sys


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

    def printAdjMatrix(self):
        # assuming that nodes' indices are 1,2,3,...,n
        n = len(self.nodes)
        for node in range(n):
            out = ''
            for adj in range(n):
                if adj + 1 != n:
                    out += '1 ' if adj + 1 in G.nodes[node + 1] else '0 '
                else:
                    out += '1' if adj + 1 in G.nodes[node + 1] else '0'
        print(out)


n = int(input())
G = Graph()
for line in sys.stdin:
    numList = list(map(int, line.split()))
    G.nodes[numList[0]] = list(numList[2:])

G.printAdjMatrix()

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

for i in range(n):
    data = [int(i) for i in input().split()]
    for j in range(data[1]):
        node = data[2 + j] - 1
        graph[i][node] = 1

for line in graph:
    print(" ".join(str(i) for i in line))

Python: n = int(input())
adm = []
for i in range(n):
    x = list(map(int,input().split()))
    tmp = [0]*n
    if x[1] == 0:
        adm.append(tmp)
    else:
        a = x[2:]
        for j in a:
            tmp[j-1] = 1
        adm.append(tmp)
for i in range(len(adm)):
    print(*adm[i])

Python: #16D8101016B IshizakiTatsuya 石崎達也 python3



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
			
print(list1)

Python: # your code goes here
#graph
#????????????????¨?????????¨
n=int(input())
L=[]
for i in range(n):
    L.append([])
    for j in range(n):
        L[i].append("0")
#rint(L)
for i in range(n):
    v=[int(i) for i in input().split()]
#    print(v)
    for j in range(2,2+v[1]):
        L[v[0]-1][v[j]-1]="1"#??????????????????1????????????i???i-1
#        print(L)
     #   L[v[j]-1][v[0]-1]="1"
for i in range(n):
    print(" ".join(L[i]))

Python: N=int(input())
M=[[0]*N for _ in[0]*N]
for e in[list(map(int,input().split()))for _ in[0]*N]:
 for v in e[2:]:M[e[0]-1][v-1]=1
for r in M:print(*r)

Python: # coding=utf-8

n = int(input())
M = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    u, k, *v = map(int, input().split())
    u = u-1 #for index
    if k == 0:
        continue
    for num in v:
        num = num-1 #for index
        M[u][num] = 1
for row in M:
    print(*row)

Python: #import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy
setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
ans=[[0]*n for _ in range(n)]
for i in range(n):
    v=list(map(int,stdin.readline().rstrip().split()))
    for j in v[2:]:
        ans[v[0]-1][j-1]=1
for i in ans:
    print(*i)

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

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

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

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):
        print(ans[i][j], end=" ")
        if j == N-1: print()

Python: n = int(input())
ls = [[] for i in range(n)]
for i in range(n):
    s = list(map(int,input().split()))
    for j in range(s[1]):
        ls[i].append(s[j+2])
ls2 = [[0 for i in range(n)] for i in range(n)]
for i in range(len(ls)):
    for j in range(len(ls[i])):
        ls2[i][ls[i][j]-1] += 1
    print(*ls2[i])

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: import numpy as np
n=int(input())
g=np.zeros((n,n),dtype=np.int)
for i in range(n):
	s=list(map(int,input().split()))
	for j in range(s[1]):
		g[s[0]][s[2+j]]+=1
print(g)

Python: 
n=int(input())

arr = [[0 for i in range(n)] for j in range(n)]
#for i in arr:
    #print(' '.join(map(str, i)))

#print(arr)

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])
            #print(x,y,z)
            arr[x-1][z-1]=1
            #print(arr)
            d=d+1

#print(arr)
for i in arr:
    print(' '.join(map(str, i)))

Python: #16D8102008K Yagyu Hazuki
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:]
    for each in v:
        dp[u-1][each-1] = 1
print(dp)

Python: N=int(input())
ad_ma=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    nums=list(map(lambda x:int(x)-1,input().split()))
    f=nums[0]
    nums=nums[2:]
    for num in nums:
        ad_ma[f][num]=1
 
  
for i in range(N):
    for j in range(N):
        if(j!=N-1):
            print(ad_ma[i][j],end=' ')
        else:
            print(ad_ma[i][j])