Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

Python: n = int(input())
matrix = [[0]*n for i in range(n)]
for _ in range(n):
    lis = list(map(int,input().split()))
    if lis[1] > 0:
        for i in lis[2:]:
            matrix[lis[0]-1][i-1] = 1

for lis in matrix:
    x = list(map(str,lis))
    print(" ".join(x))

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

for i in range(n):
	print(a[i][0],end='')
	for j in range(1, n):
		print(' ' + str(a[i][j]),end='')
	print()

Python: n = int(input())

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

for _ in range(n):
    u, k, *v = list(map(int, input().split()))
    for j in v:
        A[u-1][j-1] = 1

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

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

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

a=[[0 for i2 in range(n)]for i1 in range(n)]

for i in range(n):
    for j in range(adj[i][1]):
        a[i][adj[i][j+2]-1]=1

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

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:]:
                print(i)
                T[u][i-1] = 1

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

if __name__ == '__main__':
    main()

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def generate_graph(v_info):
    for info in v_info:
        adj_info = info[2:]
        for each in adj_info:
            adj_matrix[int(info[0]) - 1][int(each) - 1] = 1
    return adj_matrix


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    # assert len(vertex_info) == vertex_num

    ans = generate_graph(vertex_info)
    for v_result in ans:
        print(*v_result)

Python: from sys import stdin
n = int(stdin.readline())
v = [[0] * (n + 1) for i in range(n + 1)]
for u in range(1, n + 1):
    U = [int(j) for j in stdin.readline().split()]
    for k in U[2:]:
        v[u][k] += 1
for i in range(1, n + 1):
    print(*v[i][1:])

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

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

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

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

for _ in range(n):
    lst = list(map(int, input().split()))
    
    x = lst[0] - 1
    
    if lst[1] == 0:
        continue
    
    for y in lst[2:]:
        adj_list[x][y-1] = 1
    
for r in adj_list:
    print(" ".join([ str(v) for v in r]))

Python: #!/usr/bin/python3
n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    u = l[0]
    V = l[2:]
    for v in V:
        A[u - 1][v - 1] = 1
for a in A:
    print(" ".join(map(str, a)))

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):
    print(" ".join(matrices[i]))

Python: n = int(input())
m = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
  u, k, *v = map(int, input().split())
  for j in v:
    m[u-1][j-1] = 1
for i in range(n):
  print(" ".join(map(str,m[i])))

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

N = int(input())
adj = [["0"]*N for _ in range(N)]

for _ in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = "1"

for a in adj:
    print(" ".join(a))

Python: #!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n=int(input())
G=[[0]*n for i in range(n)]
for i in range(n):
    inp=tuple(map(int,input().split()))
    now=inp[0]
    for j in range(2,inp[1]+2):
        G[now-1][inp[j]-1]=1
for g in G:
    print(*g)

Python: n=int(input())
adj=[list(map(int,input().split())) for _ in range(n)]

lst=[[0 for i in range(n)] for j in range(n)]
for x in adj:
    u,v=x[0],x[2:]
    for y in v:
        lst[u-1][y-1]=1

for x in lst:
    print(" ".join(map(str,x)))

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[i][a[2+j]-1]=1
    
for i in range(N):
    print(*b[i])

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

for i in range(n):
    u=list(map(int,input().split()))

    for j in range(2,len(u)):
        G[i][u[j]-1]=1


G=[' '.join(map(str,G[i])) for i in range(n)]
print('\n'.join(G))

Python: n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l1 = list( [0 for i in range(n)] for _ in range(n))
for i in l:
  a,b,*c = i
  for j in c:
    l1[a-1][j-1] = 1
for k in l1:
  print(*k)

Python: if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for _ in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????????
    graph_table = [[0]*num for _ in range(num)]
    for d in data:
        node_id = d[0]
        num_of_e = d[1]
        for e in d[2:]:
            graph_table[node_id-1][e-1] = 1

    # ???????????????
    for row in graph_table:
        print(*row)

Python: n = int(input())

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

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    u = tmp[0]
    k = tmp[1]
    l = tmp[2:]
    for x in l:
        m[u-1][x-1] = 1

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

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

Python: N = int(input())
P = [[0 for _ in range(N)] for _ in range(N)] 
for i in range(N):
    u,k,*varray = map(int,input().split()) # u,k は数, varray は配列
    for v in varray:
        P[u-1][v-1] = 1
for j in P:
    print(" ".join(map(str,j)))