Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

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="")

Python: n = int(input())
for _ in range(n):
    u = list(map(int,input().split()))
    out = [0]*n
    for i in u[2:]: out[i-1] = 1
    print(*out)

Python: #16D8103010K Ko Okasaki
#ALDS11a

Al=[]
n=int(input())
for i in range(n):
    a=list(map(int,input().split()))
    Al.append(a[2:])
Am=[[0 for j in range(n)]for i in range(n)]

for i in range(n):
    for k in Al[i]:
            Am[i][k-1]=1
for i in range(n):
    print(*Am[i])

Python: n=int(input())
matrix=[]
for i in range(n):
    matrix.append([0]*n)
for i in range(n):
    listi=list(map(int,input().split()))
    for j in range(listi[1]):
        matrix[i][listi[j+2]-1]=1

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

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

Python: n=int(input())
a=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
    v=list(input().split())
    for j in range(len(v)):
        v[j]=int(v[j])
    x=2
    for k in range(v[1]):
        a[i][v[x+k]-1]=1
for i in range(n):
    for j in range(n):
        if j!=n-1:
            print(a[i][j],end=" ")
        else:
            print(a[i][j])

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

Python: #16D8101014F KurumeRyunosuke 2018/6/20
#import numpy as np
n=int(input())
#ls=np.zeros((n,n))
ls=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
	tmp=input().split()
	for j in range(int(tmp[1])):
		#print("*")
		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())
rlist = [[]]
alist = [[]]
for i in range (n):
    alist.append(input().split())
    rlist.append([0]*n)
alist.pop(0)
rlist.pop(0)
for i in range(n):
    for j in range(2,len(alist[i])):
        rlist[i][int(alist[i][j])-1] = 1
    print(*rlist[i])

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())
for i in range(n):
    node = list(map(int,input().split()))
    node_list = node[2:]
    matrix = ["0"]* n

    for j in node_list:
        matrix[j -1] = "1"
    print(" ".join(matrix))

Python: #ALDS1_11_A Graph
import sys

n = int(input())
A = [[0] * n for _ in range(n)]

for i in range(n):
    Adj = list(map(int, sys.stdin.readline().strip().split()))
    if Adj[1] >= 1:
        v = Adj[2:]
        for j in v:
            A[i][j - 1] = 1
            # A[j - 1][i - 1] = 1

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

Python: n=int(input())
V=[]
for i in range(n):
    temp=input().split( )
    l=len(temp)
    v=[]
    for j in range(l):
        v.append(int(temp[j]))
    V.append(v)
A=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    k=V[i][1]
    if k>0:
        for j in range(k):
            A[V[i][0]-1][V[i][j+2]-1]=1
for i in range(n):
    print(*A[i])

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

Python: n = int(input())
Adj = [[] for _ in range(n+1)]
C = [[0]*(n+1) for _ in range(n+1)]

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

for i in range(n):
    print(*C[i+1][1:])