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: #!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def generate_graph(v_info):
    for info in v_info:
        adj_info = info[2:]
        assert len(adj_info) == int(info[1])
        for each in adj_info:
            adj_matrix[int(info[0]) - 1][int(each) - 1] = 1
    return adj_matrix


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    # assert len(vertex_info) == vertex_num

    ans = generate_graph(vertex_info)
    for v_result in ans:
        print(*v_result)

Python: def convertList(G):
    n = len(G)
    GL = [ [0 for _ in range(n)] for _ in range(n)]
    for key, values in G.items():
        GL[key - 1][key - 1] = 0
        for v in values:
            GL[key - 1][v - 1] = 1

    return GL


if __name__ == '__main__':
    G = {}
    n = int(input())
    for _ in range(n):
        tmp = list(map(int, input().split()))
        u = tmp.pop(0)
        k = tmp.pop(0)
        G[u] = tmp
    GL = convertList(G)
    for i in range(n):
        print(*GL[i])

Python: num = int(input())

mat = [[0 for i in range(num)] for j in range(num)]

for i in range(num):
    arr = list(map(int,input().split()))
    
    if  arr[1] >= 1:
        for j in range(len(arr)-2):
            m = arr[j+2]
            
            mat[i][m-1] += 1

    else:
        pass

for i in range(num):
    print(*mat[i])

Python: from sys import stdin

X = [ 0 for i in range(100) ]
G = [[ 0 for i in range(100) ] for i in range(100)]

n = int(input())
for i in range(n) :
	X[i] = stdin.readline().strip().split()


for i in range(n) :
	for j in range(int(X[i][1])) :
		G[i][int(X[i][j+2])-1] = 1

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

Python: import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    Adj = [[0]*n for _ in range(n)]
    for _ in range(n):
        ukv = LI()
        u = ukv[0]
        # k = ukv[1]
        v = ukv[2:]
        for i in v:
            Adj[u-1][i-1] = 1

    for i in Adj:
        print(*i)

if __name__ == '__main__':
    resolve()

Python: n = int(input())
v_matrix = [[0 for j in range(n+1)] for i in range(n+1)]
for i in range(n):
    u, k, *v = map(int, input().split())
    for vi in v:
        v_matrix[u][vi] = 1

for row in v_matrix[1:]:
    print(" ".join(map(str, row[1:])))

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(A[i][j], end="\n")

Python: import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

    for _ in range(N):
        v, k, *U = il()
        for u in U:
            G[v - 1][u - 1] += 1

    for g in G:
        print(*g)


if __name__ == '__main__':
    main()

Python: n = int(input())
L = [[] for _ in range(n)]
for i in range(n):
    L[i] = [i for i in map(int,input().split())]
    L[i].remove(L[i][0])
    if L[i] != []:
        L[i].remove(L[i][0])
for i in range(n):
    adjacent = [0 for _ in range(n)]
    for el in L[i]:
        adjacent[el-1] = 1
    print(' '.join(map(str,adjacent)))

Python: def main():

    n = int(input())
    adj = [[0 for i in range(n)] for j in range(n)]

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

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

    for i in adj:
        print(*i)


if __name__ == "main":
    main()

Python: n = int(input())
G = [[0]*n for i in range(n)]
for i in range(n):
  u,k,*vs = map(int,input().split())
  for j in range(len(vs)):
    G[u-1][vs[j]-1] = 1 
  
for i in range(n):
  print(" ".join(map(str,G[i])))

Python: n=int(input())
graph={}

def show(nums):
    for i in range(len(nums)):
        if i!=0:
            if i!=len(nums)-1:
                print(nums[i],end=" ")
            else:
                print(nums[i])

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

Python: if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        u, k, *v = map(int, input().split())
        a = [0] * n
        for i_v in v:
            index_v = i_v -1
            a[index_v] = 1
        print(*a)

Python: 
N = int(input())
T = [[0] * (N+1) for _ in range(N+1)]
for i in range(N):
    tmp = [int(ele) for ele in input().split()]
    from_ = tmp[0]
    for j in tmp[2:]:
        T[from_][j] = 1


def main():
    for i in T[1:]:
        ans = ""
        for j in i[1:]:
            ans += str(j) + " "
        print(ans[:-1])


if __name__ == "__main__":
    main()

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

Python: N = int(input())
for i in range(N):
    u, k, *vs = map(int, input().split())
    E = [0]*N
    for v in vs:
        E[v-1] = 1
    print(*E)