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: #-*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A
"""
import itertools


def input_from_txt(number=1):
    import requests
    #url = "https://judgedat.u-aizu.ac.jp/testcases/ALDS1_4_A/8/in"
    url = "https://judgedat.u-aizu.ac.jp/testcases/ALDS1_11_A/%s/in" % number
    res = requests.get(url)
    input = res.text.split("\n")
    n = int(input[0])
    Ss = []
    for i in range(n):
        S = list(map(int, input[1+i].split()))
        Ss.append(S)
    return (n, Ss)

def input_array():
    n = int(input())
    Ss = []
    for i in range(n):
        S = list(map(int, input().split()))
        Ss.append(S)
    return (n, Ss)


if __name__ == '__main__':
    (n, Ss) = input_array()
    #(n, Ss) = input_from_txt(1)
    #print(n, Ss)
    for i in range(n):
        vth = Ss[i][0]
        vd = Ss[i][1]
        adjs = Ss[i][2:]
        row = []
        for j in range(1, 1+n):
            if j in adjs: row.append(1)
            else: row.append(0)
        print(" ".join(map(str, row)))
    #ret = get_set4(S, T)
    #ret = get_set2(S, T)
    #ret = get_set(S, T)
    #print(len(ret))

Python: n=int(input())
ans=[[0]*n for _ in range(n)]
for _ in range(n):
    v,k,*varray= map(int,input().split())
    for i in varray:
        ans[v-1][i-1]=1

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

Python: def main():
    n = int(input())
    M = [[0] * n for _ in range(n)]

    for i in range(n):
        line = input()
        inputs = [int(x) for x in line.split(' ')]
        u = inputs.pop(0)
        u -= 1                  # 0 オリジンへ変換
        _ = inputs.pop(0)
        for v in inputs:
            v -= 1              # 0 オリジンへ変換
            M[u][v] = 1

    for row in M:
        print(' '.join([str(x) for x in row]))


if __name__ == '__main__':
    main()

Python: import sys

N = int(input())
matrix = [[0]*N for _ in [0]*N]
for u, k, *v_a in (map(int, l.split()) for l in sys.stdin):
    for v in v_a:
        matrix[u-1][v-1] = 1

print(*(" ".join(map(str, row)) for row in matrix), sep="\n")

Python: if __name__ == '__main__':
    N = int(input())
    matrix = [['0'] * N for _ in range(N)]
    for i in matrix:
        node_info = [int(i) for i in input().split()]
        node_i = node_info[0] - 1
        if not node_info[1] == 0:
            for i in node_info[2:]:
                matrix[node_i][i - 1] = '1'
    [print(' '.join(line)) for line in matrix]

Python: def read_adj_list(n):
    al = [None for _ in range(n + 1)]
    for _ in range(n):
        u, _, *v = (int(x) for x in input().split())
        al[u] = v
    return al


def adj_list_to_matrix(n, al):
    am = [[0] * (n + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in al[i]:
            am[i][j] = 1
    return am


def print_adj_mat(n, am):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if j > 1:
                print(" ", end="")
            print(am[i][j], end="")
        print()


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

    adj_list = read_adj_list(n)
    adj_mat = adj_list_to_matrix(n, adj_list)
    print_adj_mat(n, adj_mat)


if __name__ == '__main__':
    main()

Python: n = int(input())

dic = {}
for _ in range(n):
    datum = list(map(int, input().split()))
    status = ["0"]*n
    for i in datum[2:]:
        status[i-1] = "1"
    print(" ".join(status))

Python: num = int(input())
L = [[ 0 for x in range(num)] for y in range(num)]
for _ in range(num):
    c,k,*v = [int(x)-1 for x in input().split()]
    for i in v:
        L[c][i] = 1
for i in range(num):
    print( *L[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]
    k = v[1]
    for j in range(k):
        a[u - 1][v[2 + j] - 1] = 1

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

Python: def resolve():
    n = int(input())
    V = [list(map(int, input().split())) for _ in range(n)]
    ans = [[0 for _ in range(n)] for _ in range(n)]
    for v, k, *a in V:
        for j in a:
            ans[v - 1][j - 1] = 1
    for a in ans:
        print(*a)


resolve()

Python: # coding: utf-8
# Your code here!

n = int(input())

ans = [[0 for _ in range(n)] for _ in range(n)]

for i in range(n):
    adj = list(map(int,input().split()))
    if adj[1] != 0:
        for j in range(2,2+adj[1]):
            ans[i][adj[j]-1] = 1
for i in range(n):
    print(*ans[i])

Python: import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    G = [[0] * n for _ in range(n)]
    for i in range(n):
        u, k, *v = map(int, input().split())
        for j in range(k):
            G[u-1][v[j]-1] = 1

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


if __name__ == '__main__':
    main()

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

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

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

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

for i in range(n):
    _ = list(map(int, input().split()))
    u = _[0] - 1  # 0オリジンに変換

    degree = _[1]
    for j in range(degree):
        v = _[j+2] - 1  # 0オリジンに変換
        M[u][v] = 1

for row in M:
    print(' '.join(map(str, row)))