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

# 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):
        print(ans[i][j], end=" ")
        if j == N-1: print()

Python: n = int(input())

Adj = [ [] for _ in range(n) ]
V = []

for i in range(n):
    V = list(map(int, input().split()))
    for i in range(V[1]):
        Adj[V[0]-1].append(V[2+i])

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

for i in range(n):
    for j in Adj[i]:
        G[i][j-1] = 1

    print(*G[i])

Python: n = int(input())
A = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    V = [int(i) for i in input().split()]
    for j in V[2:]:
        A[i][j-1] = 1
for i in A:
    tmp =""
    for j in i:
        tmp+=str(j) + " "
    print(tmp[:-1])

Python: n = int(input())
for i in range(n):
    u, k, *v, = map(int, input().split())
    r = []
    for j in range(1, n+1):
        r.append(str(1 if j in v else 0))
    print(" ".join(r))

Python: n=int(input())


#隣接リストtableを作る
table = [[0 for i in range(n)] for j in range(n)]


for _ in range(n):
    
    input_ls=list(map(int,input().split()))
    
    #頂点と辺の整理
    vertex=input_ls[0]
    edges_count=input_ls[1]
    edges=input_ls[2:]
    
    
    for k in edges:
        table[vertex-1][k-1]=1
        
        
        
for i in range(n):
    for j in range(n):
        if j!=n-1:
            print(table[i][j],end=' ')
        else:
            print(table[i][j])

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

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

Python: import sys

if __name__ == "__main__":
    lines = sys.stdin.readlines()

    # Create n * n matrix
    dimension = int(lines[0])
    matrix = []
    for x in range(dimension):
        matrix.append([0] * dimension)

    # Set edge info
    for index, line in enumerate(lines[1:]):
        for edge in [int(x) for x in line.strip().split(" ")[2:]]:
            matrix[index][edge - 1] = 1

    # Print matrix
    for row in matrix:
        print(" ".join([str(x) for x in row]))

Python: n = int(input())
for i in range(n):
    u, k, *v = map(int, input().split())
    row = ""
    for j in range(1, n + 1):
        if j in v:
            row += "1"
        else:
            row += "0"
        if j != n + 1:
            row += " "
    print(row)

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):
        print(ans[i][j], end=" ")
        if j == N-1:
            if i != N-1: print()

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

Python: n=int(input())
G=[[0 for i in range(n)]for j in range(n)]
u=[0 for i in range(n)]
for i in range(n):
    A=input().split()
    u[i]=int(A[0])
    k=int(A[1])
    for j in range(k):
        x=int(A[j+2])-1
        G[i][x]=1
print(G)

Python: N = int(input())
matrix = [[0] * N for _ in range(N)]

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

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

Python: N = int(input())

for i in range(N):
    
    tmp = input().split()
    ans = [0]*N
    
    for j in range(int(tmp[1])):
        ans[int(tmp[2+j])-1] = 1

    print(*ans)

Python: # 幅優先探索 Breadth first search: BFS

n = int(input())
A = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    dat = [int(i) for i in input().split()]
    for v in dat[2:]:
        A[dat[0]-1][v-1] = 1

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

Python: n=int(input())
l=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l2=[]
  if l1[1]==0:
    l2=["0" for j in range(n)]
  else:
    for j in range(n):
      if j+1 in l1[2:]:
        l2.append("1")
      else:
        l2.append("0")
  print(" ".join(l2))

Python: #-*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A
"""
import itertools


def input_from_txt(number=1):
    import requests
    #url = "https://judgedat.u-aizu.ac.jp/testcases/ALDS1_4_A/8/in"
    url = "https://judgedat.u-aizu.ac.jp/testcases/ALDS1_11_A/%s/in" % number
    res = requests.get(url)
    input = res.text.split("\n")
    n = int(input[0])
    Ss = []
    for i in range(n):
        S = list(map(int, input[1+i].split()))
        Ss.append(S)
    return (n, Ss)

def input_array():
    n = int(input())
    Ss = []
    for i in range(n):
        S = list(map(int, input().split()))
        Ss.append(S)
    return (n, Ss)


if __name__ == '__main__':
    (n, Ss) = input_array()
    #(n, Ss) = input_from_txt(1)
    #print(n, Ss)
    for i in range(n):
        vth = Ss[i][0]
        vd = Ss[i][1]
        adjs = Ss[i][2:]
        row = []
        for j in range(1, 1+n):
            if j in adjs: row.append(1)
            else: row.append(0)
        print(" ".join(map(str, row)))
    #ret = get_set4(S, T)
    #ret = get_set2(S, T)
    #ret = get_set(S, T)
    #print(len(ret))

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

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

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

    for i in range(n):
        line = input()
        inputs = [int(x) for x in line.split(' ')]
        u = inputs.pop(0)
        u -= 1                  # 0 オリジンへ変換
        _ = inputs.pop(0)
        for v in inputs:
            v -= 1              # 0 オリジンへ変換
            M[u][v] = 1

    for row in M:
        print(' '.join([str(x) for x in row]))


if __name__ == '__main__':
    main()

Python: import sys

N = int(input())
matrix = [[0]*N for _ in [0]*N]
for u, k, *v_a in (map(int, l.split()) for l in sys.stdin):
    for v in v_a:
        matrix[u-1][v-1] = 1

print(*(" ".join(map(str, row)) for row in matrix), sep="\n")

Python: if __name__ == '__main__':
    N = int(input())
    matrix = [['0'] * N for _ in range(N)]
    for i in matrix:
        node_info = [int(i) for i in input().split()]
        node_i = node_info[0] - 1
        if not node_info[1] == 0:
            for i in node_info[2:]:
                matrix[node_i][i - 1] = '1'
    [print(' '.join(line)) for line in matrix]