Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

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

if __name__ == "__main__":
    main()

Python: n = int(input())

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

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

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

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

Python: def main():
    num = int(input())
    T = [[0] * num for i in range(num)]
    for n in range(num):
        a = list(map(int,input().split()))
        u = a[0] - 1
        if a[1] > 0:
            for i in a[2:]:
                T[u][i-1] = 1

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

if __name__ == '__main__':
    main()

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

Python: n = int(input())

a = [[0]*n for x in range(n)]

for i in range(n):
  nood = list(map(int,input().split()))
  nood_elements = nood[0]-1
  for j in range(2,len(nood)):
    a[nood_elements][nood[j]-1] += 1
  
  for j in range(n-1):
    print(a[nood_elements][j],end=" ")
  print(a[nood_elements][n-1])

Python: n = int(input())
l = []
tmp = 0 
for _ in range(n):
    a = list(map(int,input().split()))
    l.append(a)
    if a[len(a)-1] > tmp:
        tmp = a[len(a)-1]

ans = [[0 for i in range(tmp)] for j in range(n)]
for i in range(n):
    if l[i][1] > 0:
        for j in range(2,len(l[i])):
            tmp1 = l[i][j]
            ans[i][tmp1-1] = 1

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

Python: # -*- coding: utf-8 -*-
"""
Created on Sun Jul  8 09:32:48 2018

@author: maezawa
"""

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

for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    #print(*adj[u-1])
    
for j in range(n):
    for k in adj[j]:
        a[j][k] = 1
for i in range(n):
    print(*a[i], sep=' ')

Python: # -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

N=INT()
G=[[0]*N for i in range(N)]
for i in range(N):
    l=LIST()
    u=l[0]
    l=l[2:]
    for v in l:
        G[u-1][v-1]=1

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

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("%d "%(v[i][j]))

Python: class Graph:
    def __init__(self):
        self.edges = {}

    def addVertex(self, v):
        if v not in self.edges:
            self.edges[v] = []

    def addEdge(self, from_v, to_v):
        if from_v not in self.edges:
            self.edges[from_v] = []
        if to_v not in self.edges[from_v]:
            self.edges[from_v].append(to_v)

    def isEdge(self, from_v, to_v):
        if to_v not in self.edges:
            return False
        return to_v in self.edges[from_v]

g = Graph()
n = int(input())
for i in range(n):
    u, k, *v = map(int, input().split())
    g.addVertex(u)
    for j in v:
        g.addEdge(u, j)

adj = []
for i in range(1, n+1):
    e = []
    for j in range(1, n+1):
        if g.isEdge(i, j):
            e.append(1)
        else:
            e.append(0)
    adj.append(e)

for a in adj:
    print(" ".join(map(str, a)))

Python: n = int(input())

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

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

for ret in results:
    for i in range(len(ret)):
        if i == len(ret)-1:
            print(ret[i], end='')
        else:
            print(ret[i], '', end='')
    print('')

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

for i in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:
        for adj in tmp[2:]:
            M[i][adj-1] = 1
    print(*M[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())

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

#print(arr)

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])
            #print(x,y,z)
            arr[x-1][z-1]=1
            #print(arr)
            d=d+1

print(arr)

Python: import sys

n = int(sys.stdin.readline())

for i in range(n):
    aa = list(map(int, sys.stdin.readline().split()))
    c = [0] * n
    for j in aa[2:]:
        c[j-1]=1
    print(' '.join(map(str,c)))

Python: n = int(input())
main = [[0] * (n+1) for i in range(n+1)]

for i in range(n):
	a = input().split()
	for j in range(int(a[1])):
		main[int(a[0])][int(a[j+2])] = 1

#print(main)
for i in range(1,n+1):
	print(*main[i][1:])

del a