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

# initialize
ans = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
    a = list(map(int, input().split()))
    id = a[0]
    jisu = a[1]
    for j in range(jisu):
        c = a[j+2]
        ans[i][c-1] = 1

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

Python: n = int(input())

Adj = [ [] for _ in range(n) ]
V = []

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

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

for i in range(n):
    for j in Adj[i]:
        G[i][j-1] = 1

    print(*G[i])

Python: n = int(input())
A = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    V = [int(i) for i in input().split()]
    for j in V[2:]:
        A[i][j-1] = 1
for i in A:
    tmp =""
    for j in i:
        tmp+=str(j) + " "
    print(tmp[:-1])

Python: n = int(input())
for i in range(n):
    u, k, *v, = map(int, input().split())
    r = []
    for j in range(1, n+1):
        r.append(str(1 if j in v else 0))
    print(" ".join(r))

Python: n=int(input())


#隣接リストtableを作る
table = [[0 for i in range(n)] for j in range(n)]


for _ in range(n):
    
    input_ls=list(map(int,input().split()))
    
    #頂点と辺の整理
    vertex=input_ls[0]
    edges_count=input_ls[1]
    edges=input_ls[2:]
    
    
    for k in edges:
        table[vertex-1][k-1]=1
        
        
        
for i in range(n):
    for j in range(n):
        if j!=n-1:
            print(table[i][j],end=' ')
        else:
            print(table[i][j])

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

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

Python: import sys

if __name__ == "__main__":
    lines = sys.stdin.readlines()

    # Create n * n matrix
    dimension = int(lines[0])
    matrix = []
    for x in range(dimension):
        matrix.append([0] * dimension)

    # Set edge info
    for index, line in enumerate(lines[1:]):
        for edge in [int(x) for x in line.strip().split(" ")[2:]]:
            matrix[index][edge - 1] = 1

    # Print matrix
    for row in matrix:
        print(" ".join([str(x) for x in row]))

Python: n = int(input())
for i in range(n):
    u, k, *v = map(int, input().split())
    row = ""
    for j in range(1, n + 1):
        if j in v:
            row += "1"
        else:
            row += "0"
        if j != n + 1:
            row += " "
    print(row)

Python: 
N = int(input())

# initialize
ans = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
    a = list(map(int, input().split()))
    id = a[0]
    jisu = a[1]
    for j in range(jisu):
        c = a[j+2]
        ans[i][c-1] = 1

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

Python: n = int(input())
G = []
for i in range(n):
    T = [0]*n
    G.append(T)
for i in range(n):
    L = list(map(int,input().split()))
    for j in range(2,len(L)):
        G[i][L[j]-1] += 1
for i in range(n):
  print(' '.join(map(str,G[i])))

Python: n=int(input())
G=[[0 for i in range(n)]for j in range(n)]
u=[0 for i in range(n)]
for i in range(n):
    A=input().split()
    u[i]=int(A[0])
    k=int(A[1])
    for j in range(k):
        x=int(A[j+2])-1
        G[i][x]=1
print(G)

Python: N = int(input())
matrix = [[0] * N for _ in range(N)]

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

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

Python: N = int(input())

for i in range(N):
    
    tmp = input().split()
    ans = [0]*N
    
    for j in range(int(tmp[1])):
        ans[int(tmp[2+j])-1] = 1

    print(*ans)

Python: # 幅優先探索 Breadth first search: BFS

n = int(input())
A = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    dat = [int(i) for i in input().split()]
    for v in dat[2:]:
        A[dat[0]-1][v-1] = 1

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

Python: n=int(input())
l=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l2=[]
  if l1[1]==0:
    l2=["0" for j in range(n)]
  else:
    for j in range(n):
      if j+1 in l1[2:]:
        l2.append("1")
      else:
        l2.append("0")
  print(" ".join(l2))

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