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: n = int(input())
MAP = [[0] * n for _ in range(n)]
for i in range(n):
    u, k, *v = map(int, input().split())
    for j in v:
        MAP[u - 1][j - 1] = 1
for m in MAP:
    print(*m)

Python: N=int(input())
ad_ma=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    nums=list(map(lambda x:int(x)-1,input().split()))
    f=nums[0]
    nums=nums[2:]
    for num in nums:
        ad_ma[f][num]=1

 
for i in range(N):
    for j in range(N):
        if(j!=N-1):
            print(ad_ma[i][j],end=' ')
        else:
            print(ad_ma[i][j])

Python: n=int(input())

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

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])
            arr[x-1][z-1]=1
            d=d+1

print(arr)

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

for _ in range(n):
	a = list(map(int,input().split()))
	u = a.pop(0)
	a.pop(0)
	for v in a:
		g[u-1][v-1] = 1

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

Python: # Graph
import sys
input = sys.stdin.readline
n = int(input())
A = [tuple(map(int, input().split())) for _ in range(n)]

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

for i, k, *V in A:
    for v in V:
        G[i-1][v-1] = 1

for g in G:
    print(*g)

Python: n = int(input())

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

    result = [0]*n
    count = u[1]

    for j in range(count):
        result[u[j+2]-1] = 1

    print(*result)

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

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

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())
Adj = [list(map(int, input().split())) for _ in range(n)]

m = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    if Adj[i][1]>0:
        for a in Adj[i][2:]:
            m[i][a-1] = 1
for e in m:
    print(*e)

Python: N=int(input())

M=[[0]*N for n in range(N)]
for n in range(N):
    input_temp = list(map(int,input().split()))
    for m in range(input_temp[1]):
        ad = input_temp[m+2]
        M[n][ad-1] = 1 
        
for m in M:
    print(' '.join(map(str,m)))

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

for _ in range(n):
  V = list(map(int, input().split()))
  u = V[0]
  for v in V[2:]:
    G[u - 1][v - 1] = 1

for i in G:
  print(*i)

Python: import numpy as np
n=int(input())
g=np.zeros((n,n),dtype=np.int)
for i in range(n):
	s=list(map(int,input().split()))
	for j in range(s[1]):
		g[s[0]][s[2+j]]+=1
print(g)

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(v[i][j]+" ")

Python: n = int(input())

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

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

for i in graph:
    print(*i)

Python: n=int(input())
ans=[]
for i in range(n):
  u,k,*v=list(map(int,input().split()))
  s = [0 for i in range(n)]
  for j in v:
    s[j-1]=1
  ans.append(s) 

for i in ans:
  I=map(str,i)
  print(" ".join(I))

Python: n = int(input())

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

out_list = [[0 for i in range(n)] for l in range(n)]

for a,in_lst in enumerate(lst):
    for x in range(in_lst[1]):
        out_list[a][in_lst[x+2]-1] = 1


for o1 in out_list:
    print(' '.join([str(x) for x in o1]))

Python: n = int(input())
graph = [[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(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

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

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: #16D8101016B IshizakiTatsuya 石崎達也 python3



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):
	for j in range(n):
		print(list1[i][j],end=" ")
	print()

Python: # -*- coding: utf_8 -*-

level = False
def debug(v):
    if level:
        print(v)

n = int(input())
a = []

for i in range(n):
    v = input().split()
    v.pop(0)
    v.pop(0)
    a.append([int(x) for x in v])

debug(a)

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

Python: import sys
input=sys.stdin.buffer.readline
N = int(input())
M = [[0]*N for _ in range(N)]
for _ in range(N):
    nums = list(map(int,input().split()))
    a = nums[1]
    if a == 0:
        continue
    else:
        for j in nums[2:]:
            M[nums[0]-1][j-1] = 1
for i in range(N):
    print(" ".join(map(str,M[i])))

Python: n = int(input())
Adj = []
for i in range(n):
    X = list(map(int, input().split()))[2:]
    for j in range(len(X)):
        X[j] -= 1
    Adj.append(X)
    
A = [[0]*n for _ in range(n)]
for i in range(n):
    for j in Adj[i]:
        A[i][j] = 1
for i in range(n):
    print(*A[i])

Python: def convert_adjacency_list_to_matrices():
    n = int(input())
    for _ in range(n):
        _, _, *v = map(int, input().split())
        s = set(v)
        ans = list(map(str, [int(i in s) for i in range(1, n+1)]))
        print(" ".join(ans))

if __name__ == "__main__":
    convert_adjacency_list_to_matrices()

Python: n = int(input())

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

for i in range(n):
    [*s] = map(int, input().split(' '))
    for k in range(s[1]):
        g[i][s[2 + k] - 1] = 1

for i in range(n):
    for j in range(n):
        if j != 0:
            print(' ', end='')
        print(g[i][j], end='')
    print()

Python: if __name__ == '__main__':

	n = int(input())
	
	A = [[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):
			A[i][int(cmd[2+j])-1] = 1

	for i in A:
		print(*i)