Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

Python: dat = []
n = int(input())
for i in range(n):
    dat.append([0] * n)
for i in range(n):
    s = list(map(int, input().split()))
    for j in range(len(s) - 2):

        dat[i][s[j + 2] - 1] = 1
for i in range(n):
    l = list(map(str, dat[i]))
    print(" ".join(l))

Python: n = int(input())
adj_matrix = [[0 for _ in range(n)] for _ in range(n)]
    
for i in range(n):
    l = list(map(int, input().split()))[2:]
    for j in l:
        adj_matrix[i][j-1] = 1

for l in adj_matrix:
    print(*l)

Python: # coding: utf-8

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

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

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


# 入力: 隣接リストを与える
# 出力: 隣接行列を出力する

Python: n=int(input())
G=[[0 for i in range(n)]for j in range(n)]
u=[0 for i in range(n)]
for i in range(n):
    A=input().split()
    u[i]=int(A[0])
    k=int(A[1])
    for j in range(k):
        x=int(A[j+2])-1
        G[i][x]=1
for i in range(n):
    for j in range(n):
        if j<n-1:
            print(G[i][j],end=" ")
        else:
            print(G[i][j])

Python: 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:]
    #print(u, k, v)
    for each in v:
        dp[u-1][each-1] = 1

for i in range(N):
    print(*dp[i][:])

Python: import sys
n = int(input())
input_lines = [[int(i) for i in lines.split()] for lines in sys.stdin.read().splitlines()]
for i in range(n):
    out_list = ['0'] * n
    m = len(input_lines[i])
    for j in range(m-1, 1, -1):
        out_list[input_lines[i][j]-1] = '1'
    print(' '.join(out_list))

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

Python: 
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
			
for i in range(n):
	print(*list1[i])

Python: # ??\???????????????
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]

# N*N?????£??\??????????????°?????????
graph_table = [[0]*n for i in range(n)]

# ??£??\??????????????£??\???????????????
for d in data:
    node_id = d[0]
    num_of_e = d[1]
    for e in d[2:]:#?????????????????????????????£?????????
        graph_table[node_id-1][e-1] = 1

print(graph_table)

# ??????
for g in graph_table:
    print(*g)

Python: def print_list(a):
    for x in a[:-1]:
        print(x, end=" ")
    print(a[-1])


def print_mat(a):
    for i in range(len(a)):
        print_list(a[i])


n = int(input())
adj = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    s = [int(x) for x in input().split()]
    u = s[0]
    for v in s[2:]:
        adj[u - 1][v - 1] = 1


print_mat(adj)

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

Python: n = int(input())

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

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

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

Python: g = int(input())
v = [[0] * g for _ in range(g)]
for i in range(g):
    inp = list(map(int, input().split()))
    for j in range(inp[1]):
        v[inp[0]-1][inp[2+j]-1] = 1
for row in range(g):
    for col in range(g):
        if col == g-1:
            print(v[row][col], end="")
        else:
            print(v[row][col], end=" ")
    print()

Python: import sys
data_list = []
for line in sys.stdin:
	data_list.append(line.split())

class Node():
    def __init__(self, name, transaction_list = None):
        self.transaction_list = transaction_list or []

    def add_node(self, node):
        self.transaction_list.append(node)

def convert_adjencentList_to_adjencentMatrix(adjencentList):
    adjencent_matrix = [[0 for i in range(len(adjencentList))] for j in range(len(adjencentList))]
    count = 0
    for targetList in adjencentList:
        targetList.transaction_list.sort()
        for target_index in targetList.transaction_list :
            adjencent_matrix[count][int(target_index) - 1] = 1
        count = count + 1

    for i in adjencent_matrix:
        print(*i)

if __name__ == "__main__":
        node_data_list = []

        for node_data in data_list[1:]:
            node = Node(node_data[1])
            for transaction_node in node_data[2:]:
                node.add_node(transaction_node)

            node_data_list.append(node)

        convert_adjencentList_to_adjencentMatrix(node_data_list)

Python: n=int(input())
G=[[0 for i in range(n+1)] for i in range(n+1)]
for i in range(n):
    arr=[int(x) for x in input().split()[2:]]
    for j in arr:
        
        G[i+1][j]=1
        
for k in range(1,n+1):
    G[k].pop(0)
    print(' '.join(map(str, G[k])))

Python: n = int(input())
list_m = [[0] * n for i in range(n)]
for i in range(n):
	a,b, *args = map(int,input().split())
	for num in args:
		list_m[a-1][num-1] = 1
for i in range(n):
	for j in range(n):
		list_m[i][j] = str(list_m[i][j])
for row in list_m:
	print(" ".join(row))