Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

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])

Python: n = int(input())
adj = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    if l[1] == 0:
        print(' '.join(list(map(str, adj[i]))))
        # continue
    else:
        for j in range(2,len(l)):
            adj[l[0]-1][l[j]-1] = 1
        print(' '.join(list(map(str, adj[i]))))
# for i in range(n):
    # print(' '.join(list(map(str, adj[i]))))

Python: n = int(input())
graph = [[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(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

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

Python: if __name__ == '__main__':
    n = int(input())
    graph = [[0 for i in range(n)] for _ in range(n)]
    for i in range(n):
        datas = [int(num) for num in input().split(' ')]
        if datas[1] > 0:
            for j in datas[2:]:
                graph[datas[0] - 1][j - 1] = 1

    for row in graph:
        print(str(row).replace(',', '').replace('[', '').replace(']', ''))

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

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

Python: """
隣接リストで与えられる有向グラフを，隣接行列で構成しなおす
"""
n = int(input())

for i in range(n):
    mat = [0 for _ in range(n)]
    l = list(map(int, input().split()))
    deg = l[1]
    for r in range(deg):
        index = l[r+2]-1
        mat[index] = 1
    print(' '.join(map(str, mat)))

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