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: import numpy as np
n=int(input())
ls=np.zeros((n,n))
for i in range(n):
	tmp=input().split()
	for j in range(int(tmp[1])):
		ls[i][int(tmp[j+2])-1]=1

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

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

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

    for j in inta[2:2+inta[1]]:
        ans[inta[0]-1][j-1] = 1

for i in ans:
    print(" ".join(map(str,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

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

Python: N = int(input())
G = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    u,k,*varray = map(int,input().split())
    for v in varray:
        G[u-1][v-1] = 1
    # for j in range(N):
    #     print(G[i][j])
for row in G:
    print(*row)

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

Python: class Graph:
    def __init__(self):
        self.edges = {}

    def addVertex(self, v):
        if v not in self.edges:
            self.edges[v] = []

    def addEdge(self, from_v, to_v):
        if from_v not in self.edges:
            self.edges[from_v] = []
        if to_v not in self.edges[from_v]:
            self.edges[from_v].append(to_v)

    def isEdge(self, from_v, to_v):
        if to_v not in self.edges:
            return False
        return to_v in self.edges[from_v]

g = Graph()
n = int(input())
for i in range(n):
    u, k, *v = map(int, input().split())
    g.addVertex(u)
    for j in v:
        g.addEdge(u, j)

adj = []
for i in range(1, n+1):
    e = []
    for j in range(1, n+1):
        if g.isEdge(i, j):
            e.append(1)
        else:
            e.append(0)
    adj.append(e)

for a in adj:
    for i in a:
        print(i, end=" ")
    print()

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())
B = [[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(A[1]):
        B[A[0]-1][A[j+2]-1] = 1

for i in range(n):
    for j in range(n):
        print(B[i][j],end="")
        if(j == n-1):
            print()
        else:
            print(" ",end="")

Python: 
n=int(input())
A=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    point=[int(j) for j in input().split()]
    if point[1]>0:
        for k in point[2:]:
            if k:A[i][k-1]=1
                
for i in A:
    print(*i)

Python: import sys
# sys.stdin = open('input.txt')

n = int(input())
matrix = [[0]*n for i in range(n)]
for i in range(n):
    u, k, *v = map(int, input().split())
    for j in v:
        matrix[i][j-1] = 1
for line in matrix:
    line = list(map(str, line))
    print(' '.join(line))

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):
		if j!=n-1:
			print(A[i][j], end=" ")
		else:
			print(end="\n")

Python: n=int(input())
a=[[0]*n for _ in range(n)]
u=0
k=0
for i in range(n):
    ukv=list(map(int,input().split()))
    for j in range(2,2+ukv[1]):
        a[ukv[0]-1][ukv[j]-1]=1
for i in range(n):
    print(" ".join(map(str,a[i])))

Python: N = int(input())
L = [[0]*(N+1) for i in range(N+1)]
for i in range(N):
    D = list(map(int, input().split()))
    for j in range(2,len(D)):
        L[D[0]][D[j]] = 1
for i in range(1,N+1):
    print(' '.join(map(str,L[i][1:])))

Python: N = int(input())

class Matrix:
    def __init__(self, N):
        self.M = [[0 for _ in range(N)] for _ in range(N)]
    
    def set(self, i, j, val):
        self.M[i-1][j-1] = val
    
    def __repr__(self):
        str_lines = []
        for line in self.M:
            str_lines.append(' '.join(map(str, line)))
        return '\n'.join(str_lines)

matrix = Matrix(N)

for _ in range(N):
    tmp = input().split()
    node_id = int(tmp[0])
    neighbor_num = int(tmp[1])
    neighbors = list(map(int, tmp[2:]))
    
    for n in neighbors:
        matrix.set(node_id, n, 1)

print(matrix)

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[0])] = list(map(int, numList[1:]))

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())
matrix=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    a,b,*c=input().split()
    a=int(a)
    for k in c:

        matrix[a-1][int(k)-1]=1
for i in range(len(matrix)):
    print(*matrix[i])

Python: n = int(input()) #頂点数

matrix = [[0]*n for i in range(n)]

for i in range(n):
    adj_list = list(map(int,input().split()))
    for j in adj_list[2:]: #3番目からの隣接ノードを取得する
        matrix[i][j-1] = 1 #隣接ノードを成分を1に変更する

for i in range(n):
    for j in range(n):
        if j != n-1: 
            print(matrix[i][j], end = " ")
        else:
            print(matrix[i][j])

Python: n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
#print(G)
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):
        print(G[i][j],end=" ")
    print("")

Python: def parse(line):
    params = line.split(' ')
    node = params[0]
    n_node = params[1]
    nodes = [int(p) for p in params[2:]]
    return node, n_node, nodes


def main():
    n = int(input().strip())

    for _ in range(n):
        line = input().strip()
        _, _, nodes = parse(line)
        out = ''
        for i in range(n):
            if i + 1 in nodes:
                out += '1'
            else:
                out += '0'

            if i < n - 1:
                out += ' '
        print(out)


if __name__ == '__main__':
    main()

Python: n = int(input())
for i in range(n):
    a = list(map(int,input().strip().split()))
    b = [str(int(i+1 in a[2:])) for i in range(n)]
    L=' '.join(b)
    print(L)

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

for i in range(n):
    a=list(map(int,input().split()))
    y=a[1]
    if y!=0:
        for j in range(2,2+y):
            r[i][a[j]-1]=1

for i in range(n):
    for j in range(n):
        if j!=0:
            print(" ",end="")
        print(r[i][j],end="")
    print("\n",end="")