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: #coding:utf-8
def Graph(n,A):
    ans=[]
    for i in range(n):
        line=[]
        for j in range(n):
            line.append(0)
        ans.append(line)
    for i in range(n):
        if A[i][1]!=0:
            for j in range(A[i][1]):
                ans[i][A[i][2+j]-1]=1
    for i in range(n):
        for j in range(n):
            ans[i][j]=str(ans[i][j])
        print(" ".join(ans[i]))
 
 
if __name__=="__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(list(map(int,input().split(" "))))
    Graph(n,A)

Python: 
n = int(input())

m = [[0 for i in range(n + 1)] for j in range(n + 1)]

for i in range(n):
    nums=list(map(int,input().split()))
    for j in range(nums[1]):
        m[i + 1][nums[j + 2]] = 1

for i in range(n):
    for j in range(n-1):
        print(m[i + 1][j + 1], end = " ")
    print(m[i + 1][n])

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

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

Python: n=int(input())

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

for i in range(n):
    p=[int(x) for x in input().split()]
    for j in range(n):
        if j+1 in p[2:]:
            a[i][j]=1
"""for i in range(n):
    for j in range(n):
        print(a[i][j],"",end="")
    print("")
"""
for i in range(n):
    print(*a[i])

Python: import numpy as np
n = int(input())
result = np.array([[0]*4]*4)
for _ in range(n):
  inp = list(map(int, input().split()))
  u, k = inp[0], inp[1]
  v = inp[2:]
  if k != 0:
    for vv in v:
      result[u-1][vv-1] = 1

result = list(result)
for i in range(n):
  print(*result[i])

Python: import collections
N = int(input().strip())
Adj = []
for u in range(N):
    Adju = [0 for _ in range(N)]
    Adjlst = collections.deque(list(map(int,input().strip().split(" "))))
    Adjlst.popleft()
    K = Adjlst.popleft()
    for k in range(K):
        v = Adjlst.popleft()
        Adju[v-1] = 1
    Adj.append(Adju)
for i in range(N):
    for j in range(N-1):
        print(Adj[i][j],"",end="")
    print(Adj[i][N-1])

Python: import sys


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


n = int(input())
G = Graph()
for line in sys.stdin:
    numList = list(map(int, line.split()))
    G.nodes[numList[0]] = list(numList[2:])
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)

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

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)