Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

Python: dat = []
n = int(input())
for i in range(n):
    dat.append([0] * n)
for i in range(n):
    s = list(map(int, input().split()))
    for j in range(len(s) - 2):

        dat[i][s[j + 2] - 1] = 1
for i in range(n):
    l = list(map(str, dat[i]))
    print(" ".join(l))

Python: n = int(input())
adj_matrix = [[0 for _ in range(n)] for _ in range(n)]
    
for i in range(n):
    l = list(map(int, input().split()))[2:]
    for j in l:
        adj_matrix[i][j-1] = 1

for l in adj_matrix:
    print(*l)

Python: # coding: utf-8

n = int(input())
G = [[0]*n for i in range(n)]

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

# print()
for i in range(n):
    print(*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
for i in range(n):
    for j in range(n):
        if j<n-1:
            print(G[i][j],end=" ")
        else:
            print(G[i][j])

Python: N = int(input())
dp = [[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:]
    #print(u, k, v)
    for each in v:
        dp[u-1][each-1] = 1

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

Python: import sys
n = int(input())
input_lines = [[int(i) for i in lines.split()] for lines in sys.stdin.read().splitlines()]
for i in range(n):
    out_list = ['0'] * n
    m = len(input_lines[i])
    for j in range(m-1, 1, -1):
        out_list[input_lines[i][j]-1] = '1'
    print(' '.join(out_list))

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

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

for i in range(n):
	a=list(map(int,input().split()))
	#print(a)
	if a[1]>0:
		for j in range(2,len(a)):
			list1[i][a[j]-1]=1
			
for i in range(n):
	print(*list1[i])

Python: # ??\???????????????
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]

# N*N?????£??\??????????????°?????????
graph_table = [[0]*n for i in range(n)]

# ??£??\??????????????£??\???????????????
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

print(graph_table)

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

Python: def print_list(a):
    for x in a[:-1]:
        print(x, end=" ")
    print(a[-1])


def print_mat(a):
    for i in range(len(a)):
        print_list(a[i])


n = int(input())
adj = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    s = [int(x) for x in input().split()]
    u = s[0]
    for v in s[2:]:
        adj[u - 1][v - 1] = 1


print_mat(adj)

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

Python: n = int(input())

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

for _ in range(n):
    tmp = list(map(int, input().split()))
    u = tmp[0]
    vs = tmp[2:]
    for v in vs:
        A[u-1][v-1] = 1
        
for i in range(n):
    print(' '.join(map(str, A[i])))

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

Python: g = int(input())
v = [[0] * g for _ in range(g)]
for i in range(g):
    inp = list(map(int, input().split()))
    for j in range(inp[1]):
        v[inp[0]-1][inp[2+j]-1] = 1
for row in range(g):
    for col in range(g):
        if col == g-1:
            print(v[row][col], end="")
        else:
            print(v[row][col], end=" ")
    print()

Python: import sys
data_list = []
for line in sys.stdin:
	data_list.append(line.split())

class Node():
    def __init__(self, name, transaction_list = None):
        self.transaction_list = transaction_list or []

    def add_node(self, node):
        self.transaction_list.append(node)

def convert_adjencentList_to_adjencentMatrix(adjencentList):
    adjencent_matrix = [[0 for i in range(len(adjencentList))] for j in range(len(adjencentList))]
    count = 0
    for targetList in adjencentList:
        targetList.transaction_list.sort()
        for target_index in targetList.transaction_list :
            adjencent_matrix[count][int(target_index) - 1] = 1
        count = count + 1

    for i in adjencent_matrix:
        print(*i)

if __name__ == "__main__":
        node_data_list = []

        for node_data in data_list[1:]:
            node = Node(node_data[1])
            for transaction_node in node_data[2:]:
                node.add_node(transaction_node)

            node_data_list.append(node)

        convert_adjencentList_to_adjencentMatrix(node_data_list)

Python: n=int(input())
G=[[0 for i in range(n+1)] for i in range(n+1)]
for i in range(n):
    arr=[int(x) for x in input().split()[2:]]
    for j in arr:
        
        G[i+1][j]=1
        
for k in range(1,n+1):
    G[k].pop(0)
    print(' '.join(map(str, G[k])))

Python: n = int(input())
list_m = [[0] * n for i in range(n)]
for i in range(n):
	a,b, *args = map(int,input().split())
	for num in args:
		list_m[a-1][num-1] = 1
for i in range(n):
	for j in range(n):
		list_m[i][j] = str(list_m[i][j])
for row in list_m:
	print(" ".join(row))

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

for i in range(n):
    row = list(map(int, input().split(' ')))
    Adj[row[0] - 1] = row

for adj in Adj:
    k = adj[1]
    E = adj[2:2+k]
    row = [0 for i in range(n)]
    for i in E:
        row[i - 1] = 1
    print(' '.join(map(str, row)))

Python: n = int(input())
mat = [[0] * n for _ in range(n)]
for _ in range(n):
    adj = list(map(int, input().split()))
    i = adj[0]
    for j in adj[2:]:
        mat[i - 1][j - 1] = 1
for m in mat:
    print(' '.join(map(str, m)))

Python: import sys


class Graph:
    def __init__(self, nodes={}):
        self.nodes = nodes

    def printAdjMatrix(self):
        n = len(self.nodes)
        for node in range(n):
            out = ''
            for adj in range(n):
                if adj + 1 != n:
                    out += '1 ' if adj + 1 in G.nodes[node + 1] else '0 '
                else:
                    out += '1' if adj + 1 in G.nodes[node + 1] else '0'
        print(out)


n = int(input())
G = Graph()
for line in sys.stdin:
    numList = list(map(int, line.split()))
    G.nodes[numList[0]] = list(numList[2:])

G.printAdjMatrix()

Python: n = int(input())

for i in range(n):
    s = [int(x) for x in input().split()]
    s.reverse()

    u, k = s.pop(), s.pop()
    se = set()
    for j in range(k):
        se.add(s.pop())

    ans = []
    for i in range(1, n + 1):
        ans.append(int(i in se))

    print(*ans)