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: #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())
B = [[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(A[1]):
        B[A[0]-1][A[j+2]-1] = 1

for i in range(n):
    for j in range(n):
        print(B[i][j],end="")
        if(j == n-1):
            print()
        else:
            print(" ",end="")

Python: 
n=int(input())
A=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    point=[int(j) for j in input().split()]
    if point[1]>0:
        for k in point[2:]:
            if k:A[i][k-1]=1
                
for i in A:
    print(*i)

Python: import sys
# sys.stdin = open('input.txt')

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

Python: n = int(input())

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

for i in range(n):

	B = input().split()

	if B[1]!=0:
		for j in range(int(B[1])):
			#B[2+j]
			A[i][int(B[2+j])-1] = 1

for i in range(n):
	for j in range(n):
		if j!=n-1:
			print(A[i][j], end=" ")
		else:
			print(end="\n")

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

Python: N = int(input())
L = [[0]*(N+1) for i in range(N+1)]
for i in range(N):
    D = list(map(int, input().split()))
    for j in range(2,len(D)):
        L[D[0]][D[j]] = 1
for i in range(1,N+1):
    print(' '.join(map(str,L[i][1:])))

Python: N = int(input())

class Matrix:
    def __init__(self, N):
        self.M = [[0 for _ in range(N)] for _ in range(N)]
    
    def set(self, i, j, val):
        self.M[i-1][j-1] = val
    
    def __repr__(self):
        str_lines = []
        for line in self.M:
            str_lines.append(' '.join(map(str, line)))
        return '\n'.join(str_lines)

matrix = Matrix(N)

for _ in range(N):
    tmp = input().split()
    node_id = int(tmp[0])
    neighbor_num = int(tmp[1])
    neighbors = list(map(int, tmp[2:]))
    
    for n in neighbors:
        matrix.set(node_id, n, 1)

print(matrix)

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[int(numList[0])] = list(map(int, numList[1:]))

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)

Python: N=int(input())
matrix=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    a,b,*c=input().split()
    a=int(a)
    for k in c:

        matrix[a-1][int(k)-1]=1
for i in range(len(matrix)):
    print(*matrix[i])

Python: n = int(input()) #頂点数

matrix = [[0]*n for i in range(n)]

for i in range(n):
    adj_list = list(map(int,input().split()))
    for j in adj_list[2:]: #3番目からの隣接ノードを取得する
        matrix[i][j-1] = 1 #隣接ノードを成分を1に変更する

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

Python: n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
#print(G)
for i in range(n):
    list=[int(m) for m in input().split()]
    u=list[0]
    k=list[1]
    for j in range(2,len(list)):
        v=list[j]
        G[u-1][v-1]=1
for i in range(n):
    for j in range(n):
        print(G[i][j],end=" ")
    print("")

Python: def parse(line):
    params = line.split(' ')
    node = params[0]
    n_node = params[1]
    nodes = [int(p) for p in params[2:]]
    return node, n_node, nodes


def main():
    n = int(input().strip())

    for _ in range(n):
        line = input().strip()
        _, _, nodes = parse(line)
        out = ''
        for i in range(n):
            if i + 1 in nodes:
                out += '1'
            else:
                out += '0'

            if i < n - 1:
                out += ' '
        print(out)


if __name__ == '__main__':
    main()

Python: n = int(input())
for i in range(n):
    a = list(map(int,input().strip().split()))
    b = [str(int(i+1 in a[2:])) for i in range(n)]
    L=' '.join(b)
    print(L)

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

for i in range(n):
    a=list(map(int,input().split()))
    y=a[1]
    if y!=0:
        for j in range(2,2+y):
            r[i][a[j]-1]=1

for i in range(n):
    for j in range(n):
        if j!=0:
            print(" ",end="")
        print(r[i][j],end="")
    print("\n",end="")

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

Python: #16D8103010K Ko Okasaki
#ALDS11a

Al=[]
n=int(input())
for i in range(n):
    a=list(map(int,input().split()))
    Al.append(a[2:])
Am=[[0 for j in range(n)]for i in range(n)]

for i in range(n):
    for k in Al[i]:
            Am[i][k-1]=1
for i in range(n):
    print(*Am[i])

Python: n=int(input())
matrix=[]
for i in range(n):
    matrix.append([0]*n)
for i in range(n):
    listi=list(map(int,input().split()))
    for j in range(listi[1]):
        matrix[i][listi[j+2]-1]=1

for i in range(n):
    for j in range(n-1):
        print(matrix[i][j],end=" ")
    print(matrix[i][n-1])

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

Python: n=int(input())
a=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
    v=list(input().split())
    for j in range(len(v)):
        v[j]=int(v[j])
    x=2
    for k in range(v[1]):
        a[i][v[x+k]-1]=1
for i in range(n):
    for j in range(n):
        if j!=n-1:
            print(a[i][j],end=" ")
        else:
            print(a[i][j])

Python: n = int(input())
matrix = [[0] * n for _ in range(n)]
for _ in range(n):
    line = list(map(int, input().split()))
    u = line[0]
    for v in line[2:]:
        matrix[u-1][v-1] = 1
for row in matrix:
    print(' '.join(map(str, row)))