Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			if j == n-1 {
				fmt.Printf("%d\n", Adj[i][j])
				continue
			}
			fmt.Printf("%d ", Adj[i][j])
		}
	}
}

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

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

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

Python: from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V = int(input())

table = [['0']*V for i in range(V)]

for loop in range(V):
    tmp_array = list(map(int,input().split()))
    node_id = tmp_array[0]-1
    for i in range(tmp_array[1]):
        table[node_id][tmp_array[2+i]-1] = '1'

for row in range(V):
    print(' '.join(table[row]))

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

Python: n=int(input())
L=[]
for l in range(n):
    L.append([])
M=[]
for m in range(n):
    mm=[0]*n
    M.append(mm)

for i in range(n):
    inp=list(map(int,input().split()))
    #print()
    L[inp[0]-1]=inp[2:]

for i,l in enumerate(L):
    for k in l:
        M[i][k-1]=1

for m in M:
    print(' '.join(map(str,m)))

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

while n:
    l = list(map(int, input().split()))
    cg = g[l[0] - 1]
    for i in l[2:]:
        cg[i - 1] = 1
    n -= 1

for v in g:
    print(*v)

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