Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

Python: class Node:
    def __init__(self, num, deg, neib):
        self.num = num
        self.deg = deg
        self.neib = neib


dnum = int(input())
N = []
for i in range(dnum):
    data = input().split()
    
    u = int(data[0])
    k = int(data[1])
    if k > 0:
        v = list(map(int, data[2:]))
        node = Node(u,k,v)
    else:
        node = Node(u,k,0)

    N.append(node)

O = []
for e in N:
    out = [0]*dnum
    if e.neib != 0:
        for j in e.neib:
            out[j-1] = 1
    else: pass

    O.append(out)

for i in O:
    print(*i)

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[numList[1]] = numList[1:]

for _ in range(n):
    out = ''
    for i in range(n):
        if i + 1 != n:
            out += '0 ' if i + 1 in G.nodes[1] else '1 '
        else:
            out += '0' if i + 1 in G.nodes[1] else '1'
    print(out)

Python: N = int(input())
ans = []
for i in range(N):
    a = list(map(int, input().split()))
    pre = [0 for _ in range(N)]
    for k in a[2:]:
        pre[k-1] = 1
    ans.append(pre)
for i in range(N):
    print(' '.join(list(map(str, ans[i]))))

Python: n=int(input())
da=[[0 for i in range(n)] for i in range(n)]
for i in range(n):
    se=list(map(int,input().split()))
    for j in se[2:]:
        da[i][j-1]=1
for i in range(n):
    for j in range(n):
        if j==n-1:
            print(da[i][j])
        else:
            print(da[i][j],end=' ')

Python: n = int(input())

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

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

for r in adj_mat:
    print(*r[1:])

Python: n = int(input())

A = [ [] for i in range(n)]

for i in range(n):
  A[i] = list(map(int, input().split()))

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

for i in range(n):
  a = A[i][0]
  j = A[i][1]
  if j != 0:
    for k in range(j):
      b = A[i][k+2]
      B[a-1][b-1] = 1

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

Python: import sys
def main():
    n = int(input())
    lines = sys.stdin.readlines()
    outputs = [None] * n
    str_range = [str(i) for i in range(1, n+1)]
    for i in range(n):
        idx, idx_n, *idx_vertices = lines[i].rstrip().split()
        outputs[i] = ['1' if str_i in idx_vertices else '0' for str_i in str_range]

    [print(" ".join(outputs[i])) for i in range(n)]


main()

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

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

for _ in range(N):
    l = list(map(int, input().split()))
    u, k = l.pop(0), l.pop(0)
    
    row = A[u-1]
    for x in l:
        row[x-1] = 1

for row in A:
    print(*row)

Python: n = int(input())
ans = list()
for i in range(n):
    tmp = list()
    for j in range(n):
        tmp.append(0)
    ans.append(tmp)

for i in range(n):
    l = [int(i) for i in input().split()]
    for li in l[2:]:
        # print(i, li)
        ans[i][li - 1] = 1

for i in ans:
    print(" ".join([str(x) for x in i]))

Python: 
"""
Main??????????????????
"""
# Node??°?????????
N = int(input())

# Node??????????????????????????????
nodes = [[0 for i in range(N)] for j in range(N)]

# Node??????????¨????
for i in range(N):
    j = list(map(int, input().split())) # ??\??????????§£
    no = j[0] - 1                       # Node???????????????
    childNos = j[2:]                    # ??????????´??????????

    for j in range(len(childNos)):
        childNo = childNos[j] - 1
        nodes[no][childNo] = 1


# ??¨?????????
for i in range(N):
    for j in range(N):
        if j != N -1:
            print(nodes[i][j], end=" ")
        else:
            print(nodes[i][j])

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

Python: n = int(input())

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

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