Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

Python: #16D8101014F KurumeRyunosuke 2018/6/20
#import numpy as np
n=int(input())
#ls=np.zeros((n,n))
ls=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
	tmp=input().split()
	for j in range(int(tmp[1])):
		#print("*")
		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())
rlist = [[]]
alist = [[]]
for i in range (n):
    alist.append(input().split())
    rlist.append([0]*n)
alist.pop(0)
rlist.pop(0)
for i in range(n):
    for j in range(2,len(alist[i])):
        rlist[i][int(alist[i][j])-1] = 1
    print(*rlist[i])

Python: #16D8102008K Yagyu Hazuki
n=int(input())
f = [[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:
        f[u-1][each-1] = 1
for i in range(n):
    for j in range(n):
            print(f[i][j],end=' ')
    print()

Python: n = int(input())
for i in range(n):
    node = list(map(int,input().split()))
    node_list = node[2:]
    matrix = ["0"]* n

    for j in node_list:
        matrix[j -1] = "1"
    print(" ".join(matrix))

Python: #ALDS1_11_A Graph
import sys

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

for i in range(n):
    Adj = list(map(int, sys.stdin.readline().strip().split()))
    if Adj[1] >= 1:
        v = Adj[2:]
        for j in v:
            A[i][j - 1] = 1
            # A[j - 1][i - 1] = 1

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

Python: n=int(input())
V=[]
for i in range(n):
    temp=input().split( )
    l=len(temp)
    v=[]
    for j in range(l):
        v.append(int(temp[j]))
    V.append(v)
A=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    k=V[i][1]
    if k>0:
        for j in range(k):
            A[V[i][0]-1][V[i][j+2]-1]=1
for i in range(n):
    print(*A[i])

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

Python: n = int(input())
Adj = [[] for _ in range(n+1)]
C = [[0]*(n+1) for _ in range(n+1)]

for i in range(n):
    tmp = list(map(int,input().split()))
    for j in range(tmp[1]):
        C[tmp[0]][tmp[2+j]] = 1

for i in range(n):
    print(*C[i+1][1:])

Python: import sys

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

for i in range(n):
    u, k, *A = map(int, input().split())
    for a in A:
        G[i][a-1] = 1

for g in G:
    print(*g)

Python: def main():
    n = int(input())

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


if __name__ == "__main__":
    main()

Python: n = int(input())
G = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    S = list(map(int, input().split()))
    tmp_n = S[1]
    for j in range(tmp_n):
        G[i][S[j+2]-1] = 1
for i in range(n):
    print(*G[i])

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

M=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in A[i][2:]:
        M[i][j-1]=1

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

Python: from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V = int(input())

table = [['0']*V for i in range(V)]

for loop in range(V):
    tmp_array = list(map(int,input().split()))
    node_id = tmp_array[0]-1
    for i in range(tmp_array[1]):
        table[node_id][tmp_array[2+i]-1] = '1'

for row in range(V):
    print(' '.join(table[row]))

Python: import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    n = int(input())
    edge = [[0]*n for i in range(n)]

    for i in range(n):
        u, k, *vs = [int(j) - 1 for j in input().split()]
        # debug(vs, locals())
        for v in vs:
            edge[u][v] = 1

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

    pass

if __name__ == '__main__':
    solve()

Python: import sys
input = sys.stdin.readline

def getNeighbor(A, i):
    a = len(A)
    for k in range(2, a):
        C[i][A[k]-1] = 1

N = int(input())
C = [[0]*N for _ in range(N)]
for i in range(N):
    A = list(map(int, input().split()))
    getNeighbor(A,i)
for i in range(N):
    print(*C[i])

Python: from sys import stdin
input = stdin.readline

n = int(input())
M = [['0']*n for _ in range(n)] # 0オリジンの隣接行列、0で初期化しておく

for _ in range(n):
    u, k, *vv = input().split()
    u = int(u)-1  # 0オリジンにする
    k = int(k)    # kは使わない
    for v in vv:
        v = int(v)-1  # 0オリジンにする
        M[u][v] = '1' #最後に出力するときstr型である必要があるので、str型で入力

for m in M:
    print(' '.join(m)) # 空白入れて出力

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

Python: v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = [int(n) for n in input().split(" ")]
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])

Python: n = int(input())
answerL = []
for i in range(n):
    inputL = input().split()
    newL = [0]*n
    k = int(inputL[1])
    for j in range(k):
        target = int(inputL[1+j+1])
        newL[target-1] = 1
    answerL.append(newL)
for ans in answerL:
    print(' '.join(list(map(str, ans))))

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

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]-1][s[2+j]-1]+=1
print(g)

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def generate_graph(v_info):
    for info in v_info:
        adj_info = info[2:]
        assert len(adj_info) == int(info[1])
        for each in adj_info:
            adj_matrix[int(info[0]) - 1][int(each) - 1] = 1
    return adj_matrix


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    # assert len(vertex_info) == vertex_num

    ans = generate_graph(vertex_info)
    for v_result in ans:
        print(*v_result)