Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

Python: import numpy as np
n = int(input())
result = np.array([[0]*4]*4)
for _ in range(n):
  inp = list(map(int, input().split()))
  u, k = inp[0], inp[1]
  v = inp[2:]
  if k != 0:
    for vv in v:
      result[u-1][vv-1] = 1

result = list(result)
for i in range(n):
  print(*result[i])

Python: import collections
N = int(input().strip())
Adj = []
for u in range(N):
    Adju = [0 for _ in range(N)]
    Adjlst = collections.deque(list(map(int,input().strip().split(" "))))
    Adjlst.popleft()
    K = Adjlst.popleft()
    for k in range(K):
        v = Adjlst.popleft()
        Adju[v-1] = 1
    Adj.append(Adju)
for i in range(N):
    for j in range(N-1):
        print(Adj[i][j],"",end="")
    print(Adj[i][N-1])

Python: import sys


class Graph:
    def __init__(self, nodes={}):
        self.nodes = nodes


n = int(input())
G = Graph()
for line in sys.stdin:
    numList = list(map(int, line.split()))
    G.nodes[numList[0]] = list(numList[2:])
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())
v = [[0]*n  for _ in range(n)]
for i in range(n):
  l = list(map(int,input().split()))
  u = l[0]
  k = l[1]
  c = l[2:]
  for j in c:
    v[u-1][j-1]=1
for m in v:
    print(' '.join(map(str, m)))

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

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

for row in A:
    msg = ' '.join(map(str, row))
    print(msg)

Python: from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V = int(input())

table = [['0']*V for i in range(V)]

for loop in range(V):
    tmp_array = list(map(int,input().split()))
    node_id = tmp_array[0]-1
    for i in range(tmp_array[1]):
        table[node_id][tmp_array[2+i]-1] = '1'

for row in range(V):
    print(' '.join(table[row]))

Python: from sys import stdin
n = int(stdin.readline())
v = [[0] * n for _ in range(n)]
for u in range(n):
    l = list(map(int, stdin.readline().split()))
    for k in l[2:]:
        v[u][k - 1] = 1
    print(*v[u])

Python: n=int(input())
L=[]
for l in range(n):
    L.append([])
M=[]
for m in range(n):
    mm=[0]*n
    M.append(mm)

for i in range(n):
    inp=list(map(int,input().split()))
    #print()
    L[inp[0]-1]=inp[2:]

for i,l in enumerate(L):
    for k in l:
        M[i][k-1]=1

for m in M:
    print(' '.join(map(str,m)))

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

while n:
    l = list(map(int, input().split()))
    cg = g[l[0] - 1]
    for i in l[2:]:
        cg[i - 1] = 1
    n -= 1

for v in g:
    print(*v)

Python: n = int(input())
MAP = [[0] * n for _ in range(n)]
for i in range(n):
    u, k, *v = map(int, input().split())
    for j in v:
        MAP[u - 1][j - 1] = 1
for m in MAP:
    print(*m)

Python: N=int(input())
ad_ma=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    nums=list(map(lambda x:int(x)-1,input().split()))
    f=nums[0]
    nums=nums[2:]
    for num in nums:
        ad_ma[f][num]=1

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

Python: n=int(input())

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

for i in range(0,n):
    l=raw_input().split()
    if(int(l[1])>=1):
        x=int(l[0])
        y=int(l[1])
        p=len(l)
        d=0
        while(2+d<p):
            z=int(l[2+d])
            arr[x-1][z-1]=1
            d=d+1

print(arr)

Python: n = int(input())
g = [[0 for _ in range(n)] for _ in range(n)]

for _ in range(n):
	a = list(map(int,input().split()))
	u = a.pop(0)
	a.pop(0)
	for v in a:
		g[u-1][v-1] = 1

for a in g:
	print(" ".join(map(str,a)))

Python: # Graph
import sys
input = sys.stdin.readline
n = int(input())
A = [tuple(map(int, input().split())) for _ in range(n)]

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

for i, k, *V in A:
    for v in V:
        G[i-1][v-1] = 1

for g in G:
    print(*g)

Python: n = int(input())

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

    result = [0]*n
    count = u[1]

    for j in range(count):
        result[u[j+2]-1] = 1

    print(*result)

Python: N = int(input())
adj = [[0 for j in range(N)] for i in range(N)]
for _ in range(N):
    u, k, *v = input().split()
    for i in v:
        adj[int(u)-1][int(i)-1] = 1

for a in adj:
    print(" ".join(map(str, a)))

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())
Adj = [list(map(int, input().split())) for _ in range(n)]

m = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    if Adj[i][1]>0:
        for a in Adj[i][2:]:
            m[i][a-1] = 1
for e in m:
    print(*e)

Python: N=int(input())

M=[[0]*N for n in range(N)]
for n in range(N):
    input_temp = list(map(int,input().split()))
    for m in range(input_temp[1]):
        ad = input_temp[m+2]
        M[n][ad-1] = 1 
        
for m in M:
    print(' '.join(map(str,m)))

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

for _ in range(n):
  V = list(map(int, input().split()))
  u = V[0]
  for v in V[2:]:
    G[u - 1][v - 1] = 1

for i in G:
  print(*i)

Python: import numpy as np
n=int(input())
g=np.zeros((n,n),dtype=np.int)
for i in range(n):
	s=list(map(int,input().split()))
	for j in range(s[1]):
		g[s[0]][s[2+j]]+=1
print(g)