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

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