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()) #頂点数

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

for i in range(n):
    adj_list = list(map(int,input().split()))
    for j in adj_list[2:]: #3番目からの隣接ノードを取得する
        matrix[i][j-1] = 1 #隣接ノードを成分を1に変更する

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

Python: n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
#print(G)
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: def parse(line):
    params = line.split(' ')
    node = params[0]
    n_node = params[1]
    nodes = [int(p) for p in params[2:]]
    return node, n_node, nodes


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

    for _ in range(n):
        line = input().strip()
        _, _, nodes = parse(line)
        out = ''
        for i in range(n):
            if i + 1 in nodes:
                out += '1'
            else:
                out += '0'

            if i < n - 1:
                out += ' '
        print(out)


if __name__ == '__main__':
    main()

Python: n = int(input())
for i in range(n):
    a = list(map(int,input().strip().split()))
    b = [str(int(i+1 in a[2:])) for i in range(n)]
    L=' '.join(b)
    print(L)

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

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

for i in range(n):
    for j in range(n):
        if j!=0:
            print(" ",end="")
        print(r[i][j],end="")
    print("\n",end="")

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

Python: #16D8103010K Ko Okasaki
#ALDS11a

Al=[]
n=int(input())
for i in range(n):
    a=list(map(int,input().split()))
    Al.append(a[2:])
Am=[[0 for j in range(n)]for i in range(n)]

for i in range(n):
    for k in Al[i]:
            Am[i][k-1]=1
for i in range(n):
    print(*Am[i])

Python: n=int(input())
matrix=[]
for i in range(n):
    matrix.append([0]*n)
for i in range(n):
    listi=list(map(int,input().split()))
    for j in range(listi[1]):
        matrix[i][listi[j+2]-1]=1

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

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

Python: n=int(input())
a=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
    v=list(input().split())
    for j in range(len(v)):
        v[j]=int(v[j])
    x=2
    for k in range(v[1]):
        a[i][v[x+k]-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])

Python: n = int(input())
matrix = [[0] * n for _ in range(n)]
for _ in range(n):
    line = list(map(int, input().split()))
    u = line[0]
    for v in line[2:]:
        matrix[u-1][v-1] = 1
for row in matrix:
    print(' '.join(map(str, row)))

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

Python: #16D8102008K Yagyu Hazuki
n=int(input())
f = [[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:]
    for each in v:
        f[u-1][each-1] = 1
for i in range(n):
    for j in range(n):
            print(f[i][j],end=' ')
    print()

Python: n = int(input())
for i in range(n):
    node = list(map(int,input().split()))
    node_list = node[2:]
    matrix = ["0"]* n

    for j in node_list:
        matrix[j -1] = "1"
    print(" ".join(matrix))

Python: #ALDS1_11_A Graph
import sys

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

for i in range(n):
    Adj = list(map(int, sys.stdin.readline().strip().split()))
    if Adj[1] >= 1:
        v = Adj[2:]
        for j in v:
            A[i][j - 1] = 1
            # A[j - 1][i - 1] = 1

for i in A:
    print(' '.join(map(str, i)))

Python: n=int(input())
V=[]
for i in range(n):
    temp=input().split( )
    l=len(temp)
    v=[]
    for j in range(l):
        v.append(int(temp[j]))
    V.append(v)
A=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    k=V[i][1]
    if k>0:
        for j in range(k):
            A[V[i][0]-1][V[i][j+2]-1]=1
for i in range(n):
    print(*A[i])

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

Python: n = int(input())
Adj = [[] for _ in range(n+1)]
C = [[0]*(n+1) for _ in range(n+1)]

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

for i in range(n):
    print(*C[i+1][1:])