Go: package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const N = 100

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var M [N][N]int
	for i := 0; i < n; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		u--
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			v--
			M[u][v] = 1
		}
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			out.WriteString(fmt.Sprintf("%d", M[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}

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

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