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: n = int(input())

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

for i in range(n):
    row = [ int(r) for r in input().split()]
    u = row[0] - 1
    if (row[1] > 0):
        for j in range(row[1]):
            v = row[2 + j] - 1
            A[u][v] = 1
            
for i in range(n):
    print(" ".join([str(st) for st in A[i]]))

Python: n = int(input())
M = [[0] * n for i in range(n)]
for i in range(n):
    t = list(map(int, input().split()))
    v = t[0]
    k = t[1]
    for j in range(k):
        M[v - 1][t[2+j] - 1] = 1

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

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

while n:
    l = list(map(int, input().split()))
    column_g = g[l[0] - 1]
    for i in l[2:]:
        column_g[i-1] = 1
    n -= 1
for v in column_g:
    print(*v)

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(line) for line in matrix]

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

for i in range(N):
    ls = list(map(int,input().split()))
    u = ls[0] - 1
    for v in ls[2:]:
        G[u][v-1] = 1

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

Python: n = int(input())
m = [[0] * n for i in range(n)]
for i in range(n):
    line = [int(v) for v in input().split()]
    u = line[0] - 1
    for v in line[2:]:
        v -= 1
        m[u][v] = 1

for row in m:
    print(' '.join([str(v) for v in row]))

Python: def main():

    n = int(input())
    e = [[0]*n for _ in range(n)]

    for i in range(n):
        m = list(map(int,input().split()))
        for j in range(2,len(m)):
            e[m[0]-1][m[j]-1] = 1

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

if __name__ == '__main__':
    main()

Python: n = int(input())
in_list = []
for i in range(n):
    in_list.append(list(map(int, input().split())))

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

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = 1

for i in range(n):
    s = ""
    for m in matrices[i]:
        s += str(m) + " "
    print(s)

Python: # coding: utf-8
N = int(input().rstrip())
A = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    line = [int(i) for i in input().rstrip().split()]
    for j in range(line[1]):
        A[line[0]-1][line[j+2]-1] = 1

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

Python: def main():
    n = int(input())
    m = [[0 for j in range(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)):
            m[d[0]][d[j]] = 1

    for i in range(1, n+1):
        print(" ".join([str(m[i][j]) for j in range(1, len(m[i]))]))


if __name__ == '__main__':
    main()

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def generate_graph(v_info):
    for info in v_info:
        adj_info = info[2:]
        for each in adj_info:
            adj_matrix[int(info[0]) - 1][int(each) - 1] = 1
    return adj_matrix


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    # assert len(vertex_info) == vertex_num

    ans = generate_graph(vertex_info)
    for v_result in ans:
        print(*v_result)

Python: n=int(input())

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

for i in range(0,n):
    l=raw_input().split()
    if(int(l[1])>=1):
        x=int(l[0])
        y=int(l[1])
        p=len(l)
        d=0
        while(2+d<p):
            z=int(l[2+d])
            arr[x-1][z-1]=1
            d=d+1

print(arr)

Python: n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
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: n = int(input())
GM = [[0]*n for i in range(n)]

for i in range(n):
    data = list(map(int,input().split()))
    for i in range(data[1]):
        GM[data[0]-1][data[i+2]-1] = 1

    print(*GM[i])

Python: n = int(input())
M = [[0] * n for i in range(n)]
u_k_v = [list(map(int, input().split())) for i in range(n)]

for i in u_k_v:
    u, k, V = i[0] - 1, i[1], i[2:]
    for v in V:
        M[u][v - 1] = 1
 
for i in range(n):
    for j in range(n):
        print(M[i][j], end  = ' ')
    print()

Python: # Graph I - Graph
n = int(input())
for _ in range(n):
    ss = list(map(int, input().split()))
    u = ss[0] - 1
    row = [0 for _ in range(n)]
    for i in range(ss[1]):
        idx = 2 + i
        row[ss[idx]-1] = 1
    print(*row)

Python: n = int(input())

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

for _ in range(n):
    array = list(map(int, input().split()))
    u = array[0]
    k = array[1]
    for i in range(2, len(array)):
        mat[u - 1][array[i] - 1] = 1
        # mat[array[i] - 1][u - 1] = 1

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

Python: n = int(input())
l = []
pad = 0
for i in range(n):
    m = [0]*n
    s = list(map(int,input().split()))
    if s[1] != 0:
        for j in s[2:]:
            m[j-1] = 1
    
    print(*m)