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())
v = [[0] * n for _ in range(n)] 
for i in range(0,n):
  l = list(map(int,input().split()))
  u = l[0]
  k = l[1]
  for j in l[2:]:
    v[i-1][j-1]=1

for i in range(n):
  for j in range(n):
    print(v[i][j]+" ")

Python: n = int(input())

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

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

for i in graph:
    print(*i)

Python: n=int(input())
ans=[]
for i in range(n):
  u,k,*v=list(map(int,input().split()))
  s = [0 for i in range(n)]
  for j in v:
    s[j-1]=1
  ans.append(s) 

for i in ans:
  I=map(str,i)
  print(" ".join(I))

Python: n = int(input())

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

out_list = [[0 for i in range(n)] for l in range(n)]

for a,in_lst in enumerate(lst):
    for x in range(in_lst[1]):
        out_list[a][in_lst[x+2]-1] = 1


for o1 in out_list:
    print(' '.join([str(x) for x in o1]))

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

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

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

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: #16D8101016B IshizakiTatsuya 石崎達也 python3



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):
	for j in range(n):
		print(list1[i][j],end=" ")
	print()

Python: # -*- coding: utf_8 -*-

level = False
def debug(v):
    if level:
        print(v)

n = int(input())
a = []

for i in range(n):
    v = input().split()
    v.pop(0)
    v.pop(0)
    a.append([int(x) for x in v])

debug(a)

for i in range(0, n):
    v = a[i]
    for j in range(n):
        if (j + 1) in v:
            print(str(1), end="")
        else:
            print(str(0), end="")
        if j != n - 1:
            print(" ", end="")
    print()

Python: import sys
input=sys.stdin.buffer.readline
N = int(input())
M = [[0]*N for _ in range(N)]
for _ in range(N):
    nums = list(map(int,input().split()))
    a = nums[1]
    if a == 0:
        continue
    else:
        for j in nums[2:]:
            M[nums[0]-1][j-1] = 1
for i in range(N):
    print(" ".join(map(str,M[i])))

Python: n = int(input())
Adj = []
for i in range(n):
    X = list(map(int, input().split()))[2:]
    for j in range(len(X)):
        X[j] -= 1
    Adj.append(X)
    
A = [[0]*n for _ in range(n)]
for i in range(n):
    for j in Adj[i]:
        A[i][j] = 1
for i in range(n):
    print(*A[i])

Python: def convert_adjacency_list_to_matrices():
    n = int(input())
    for _ in range(n):
        _, _, *v = map(int, input().split())
        s = set(v)
        ans = list(map(str, [int(i in s) for i in range(1, n+1)]))
        print(" ".join(ans))

if __name__ == "__main__":
    convert_adjacency_list_to_matrices()

Python: n = int(input())

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

for i in range(n):
    [*s] = map(int, input().split(' '))
    for k in range(s[1]):
        g[i][s[2 + k] - 1] = 1

for i in range(n):
    for j in range(n):
        if j != 0:
            print(' ', end='')
        print(g[i][j], end='')
    print()

Python: if __name__ == '__main__':

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

	for i in range(n):
		cmd = input().split();
		m = int(cmd[1])
		for j in range(m):
			A[i][int(cmd[2+j])-1] = 1

	for i in A:
		print(*i)

Python: #16D8101014F KurumeRyunosuke 2018/6/20
import numpy as np
n=int(input())
ls=np.zeros((n,n))
for i in range(n):
	tmp=input().split()
	#print(tmp)
	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())
a = [[0 for i in range(n)] for j 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
    print(*a[u - 1])

Python: n = int(input())

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

for _ in range(n):
    In = list(map(int, input().split()))
    u, k, vs = In[0], In[1], In[2:]
    for v in vs:
        mat[u - 1][v - 1] = 1

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

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

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

for i in range(n):
    for j in range(n):
        print(B[i][j]," ",end="")
    print()

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

for _ in range(n):
    u, k, *V = map(int, input().split())
    if k == 0:
        continue
    for j in V:
        graph[u-1][j-1] = 1

for g in graph:
    print(' '.join(map(str, g)))

Python: n = int(input())

adj_mat = [[0] * (n + 1) for j in range(n)]

for i in range(n):
    adj_list_i = list(map(int, input().split()[2:]))
    for j in adj_list_i:
        adj_mat[i][j] = 1

for r in adj_mat:
    print(*r[1:])