Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

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:]
    for each in v:
        dp[u-1][each-1] = 1
for i in range(n):
    for j in range(n):
            print(dp[i][j],end=' ')
    print()

Python: N = int(input())
L = [list(map(int, input().split())) for i in range(N)]
adj = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
  for node in L[i][2:]:
    adj[i][node-1] = 1

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

Python: n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
    list=[int(m) for m in input().split()]
    u=list[0]
    k=list[1]
    for j in range(2,len(list)):
        v=list[j]
        G[u-1][v-1]=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],end="\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):
        if j != N-1:
            print(ans[i][j], end=" ")
        else:
            print(ans[i][j])

Python: N=int(input())
for _ in[0]*N:
 r=[0]*N
 for i in input().split()[2:]:r[int(i)-1]=1
 print(*r)

Python: def Main():
    N = int(input())
    adj = [[0]*N for i in range(N)]

    for n in range(N):
        u, k, *V = map(int, input().split())
        
        if k > 0:
           for i in V:
            adj[u - 1][i - 1] = 1

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

Main()

Python: import sys


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


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

for _ in range(n):
    out = ''
    for i in range(n):
        if i + 1 != n:
            out += '0 ' if i + 1 in G.nodes[1] else '1 '
        else:
            out += '0' if i + 1 in G.nodes[1] else '1'
    print(out)

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):
    s = ""
    for m in matrices[i]:
        s += str(m) + " "
    print(s)

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

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

Python: import sys
input = sys.stdin.readline
n = int(input())
G = {i: [] for i in range(1, n+1)}
for _ in range(n):
    tmp = list(map(int, input().split()))
    G[tmp[0]] += tmp[2:] if tmp[1]>0 else []

adj = [[0]*(1+n) for _ in range(1+n)]
for i in range(1, n+1):
    for j in G[i]:
        adj[i][j] = 1
for i in range(1, n+1):
    print(*adj[i][1:])

Python: # coding: UTF-8
n = int(input())
Ans =[ [0 for i in range(n)] for j in range(n)]
for l in range(n):
  raw = list(map(int,input().split()))
  i = raw[0]
  d = raw[1]
  for m in range(2,d+2):
    Ans[i-1][raw[m]-1] = 1

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

Python: N=int(input())
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(N)] for i in range(N)]

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

for i in S:
    print(*i)

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


if __name__ == '__main__':

    n = int(input())
    M = [[0 for i in range(n)] for j in range(n)]
    for _ in range(n):
        l = list(map(int, input().split(" ")))
        u = l[0]
        k = l[1]
        if k != 0:
            for v in l[2:]:
                M[u-1][v-1] = 1
        
    for r in M:
        print(" ".join(map(str, r)))

Python: def main():
    n = int(input())
    
    graph = [[0 for _ in range(n)] for _ in range(n)]

    for _ in range(n):
        u, k, *v_s = map(int, input().split(' '))
        for j in range(k):
            graph[u-1][v_s[j-1]-1] = 1
    
    for row in graph:
        print(' '.join(map(str, row)))


if __name__ == "__main__":
    main()

Python: n = int(input())

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

for i in range(n):

	B = input().split()

	if B[1]!=0:
		for j in range(int(B[1])):
			#B[2+j]
			A[i][int(B[2+j])-1] = 1

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

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

Python: n=int(input())
V=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
	v=[int(j) for j in input().split(" ")]
	u=v.pop(0)
	k=v.pop(0)
	for j in range(k):
		V[u-1][v[j]-1]=1



for i in range(n):
	print(" ".join([str(j) for j in V[i]]))

Python: n = int(input())

for i in range(n):
    nums = list(map(int, input().split()))
    ans = ['0'] * n
    for j in nums[2:]:
        ans[j-1] = '1'
    print(' '.join(ans))

Python: #!/usr/bin/env python3
import sys
sys.setrecursionlimit(15000)
n = int(sys.stdin.readline())

ret = []
inp = sys.stdin.readlines()
G = [[0]*n for _ in range(n)]
for i in range(n):
  v = list(map(int,inp[i].split()))
  for j in v[2:]:
    G[v[0]-1][j-1] = 1
  print(" ".join(map(str,G[i])))

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
        g[a[j + 2] - 1][a[0] - 1] = 1

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

Python: v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = (int(n) for n in input().split(" "))
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])

Python: #演習2－10

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

for i in range(n):
    cmd = input().split();
    m = int(cmd[1])
    for j in range(m):
        mat[i][int(cmd[2+j])-1] = 1

for i in mat:
    print(*i)

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

class Graph:
    def __init__(self,Vertex,Edge):
        self.V = Vertex
        self.E = Edge

Edge = [i+1 for i in range(N)]
Vertex = []
for i in range(N):
    for j in range(2,A[i][1]+2):
        Vertex.append((A[i][0],A[i][j]))

g = Graph(Vertex,Edge)

R = [[0 for j in range(N)] for i in range(N)]
for i in range(N):
    for j in range(N):
        if (i+1,j+1) in g.V:
            R[i][j] = 1

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

Python: from sys import stdin
from collections import deque

def print_2d_array(A):
    for i in range(1, len(A)):
        print(*A[i][1:], sep=" ")

def read_and_print_graph(n):
    A = [ [0]*(n+1) for _ in range(n+1) ]
    for _ in range(n):
        line = deque(stdin.readline().strip().split())
        i = line.popleft()
        line.popleft()
        for k in line:
            A[int(i)][int(k)] = 1
    print_2d_array(A)

n = int(input())
read_and_print_graph(n)