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: 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(A[i][j], end="\n")

Python: import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    G = [[0] * N for _ in range(N)]

    for _ in range(N):
        v, k, *U = il()
        for u in U:
            G[v - 1][u - 1] += 1

    for g in G:
        print(*g)


if __name__ == '__main__':
    main()

Python: n = int(input())
L = [[] for _ in range(n)]
for i in range(n):
    L[i] = [i for i in map(int,input().split())]
    L[i].remove(L[i][0])
    if L[i] != []:
        L[i].remove(L[i][0])
for i in range(n):
    adjacent = [0 for _ in range(n)]
    for el in L[i]:
        adjacent[el-1] = 1
    print(' '.join(map(str,adjacent)))

Python: def main():

    n = int(input())
    adj = [[0 for i in range(n)] for j in range(n)]

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

    for i in range(n):
        print(" ".join(list(map(str, adj[i]))))

    for i in adj:
        print(*i)


if __name__ == "main":
    main()

Python: n = int(input())
G = [[0]*n for i in range(n)]
for i in range(n):
  u,k,*vs = map(int,input().split())
  for j in range(len(vs)):
    G[u-1][vs[j]-1] = 1 
  
for i in range(n):
  print(" ".join(map(str,G[i])))

Python: n=int(input())
graph={}

def show(nums):
    for i in range(len(nums)):
        if i!=0:
            if i!=len(nums)-1:
                print(nums[i],end=" ")
            else:
                print(nums[i])

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

Python: if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        u, k, *v = map(int, input().split())
        a = [0] * n
        for i_v in v:
            index_v = i_v -1
            a[index_v] = 1
        print(*a)

Python: 
N = int(input())
T = [[0] * (N+1) for _ in range(N+1)]
for i in range(N):
    tmp = [int(ele) for ele in input().split()]
    from_ = tmp[0]
    for j in tmp[2:]:
        T[from_][j] = 1


def main():
    for i in T[1:]:
        ans = ""
        for j in i[1:]:
            ans += str(j) + " "
        print(ans[:-1])


if __name__ == "__main__":
    main()

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

Python: N = int(input())
for i in range(N):
    u, k, *vs = map(int, input().split())
    E = [0]*N
    for v in vs:
        E[v-1] = 1
    print(*E)

Python: n=int(input())

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

for i in range(n):
    p=[int(x) for x in input().split()]
    for j in range(n):
        if j+1 in p[2:]:
            a[i][j]=1
for i in range(n):
    for j in range(n):
        print(a[i][j]," ",end="")
    print("")

Python: n = int(input())

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

for i in range(n):

    u, k, *V = map(int, input().split())

    for v in V:
        v -= 1
        matrix[i][v] = 1


for row in matrix:
    print(*row)

Python: import sys

input = sys.stdin.readline
n = int(input())
adj_list = [[0]*n for _ in range(n)]
for _ in range(n):
    input_list = list(map(int, input().split()))
    u = input_list[0] - 1
    e_num = input_list[1]
    if e_num > 0:
        for i in range(e_num):
            adj_list[u][input_list[i+2] - 1] = 1

for adj in adj_list:
    print(' '.join(map(str, adj)))

Python: 


n=int(input())
graph=[[0]*n for loop in range(n)]
for loop in range(n):
    tmp_ope=list(map(int,input().split()))
    for j in range(tmp_ope[1]):
        graph[tmp_ope[0]-1][tmp_ope[j+2]-1]=1

for loop in range(n):
    for j in range(0,n-1):
        print(f"{graph[loop][j]}",end=" ")
    print(f"{graph[loop][n-1]}")

Python: # coding: utf-8
n = int(input().rstrip())

for i in range(n):
    line = input().rstrip().split(" ")
    lineMax = int(line[1])
    lineIndex = 0
    for j in range(n):
        if lineIndex >= lineMax:
            print(0, end = "")
        else:
            if j + 1 == int(line[lineIndex + 2]):
                print(1, end = "")
                lineIndex += 1
            else:
                print(0, end = "")
        if j + 1 != n:
            print(" ", end ="")
    print()

Python: #coding:utf-8

n = int(input())
mtrx = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    data = list(input().split())
    adjs = int(data[1])
    for adj in range(adjs):
        j = int(data[adj+2]) - 1
        mtrx[i][j] = 1
for col in mtrx:
    print(" ".join([str(num) for num in col]))