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: 


n=int(input())
graph=[[0]*n for loop in range(n)]
for loop in range(n):
    tmp_ope=list(map(int,input().split()))
    for j in range(tmp_ope[1]):
        graph[tmp_ope[0]-1][tmp_ope[j+2]-1]=1

for loop in range(n):
    for j in range(0,n-1):
        print(f"{graph[loop][j]}",end=" ")
    print(f"{graph[loop][n-1]}")

Python: # coding: utf-8
n = int(input().rstrip())

for i in range(n):
    line = input().rstrip().split(" ")
    lineMax = int(line[1])
    lineIndex = 0
    for j in range(n):
        if lineIndex >= lineMax:
            print(0, end = "")
        else:
            if j + 1 == int(line[lineIndex + 2]):
                print(1, end = "")
                lineIndex += 1
            else:
                print(0, end = "")
        if j + 1 != n:
            print(" ", end ="")
    print()

Python: #coding:utf-8

n = int(input())
mtrx = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    data = list(input().split())
    adjs = int(data[1])
    for adj in range(adjs):
        j = int(data[adj+2]) - 1
        mtrx[i][j] = 1
for col in mtrx:
    print(" ".join([str(num) for num in col]))

Python: def main():
    n=int(input())
    v=[]
    array=[]
    for i in range(n):
        zero=[0 for i in range(n)]
        a=list(map(int,input().split()))
        a=a[2:]
        for j in a:
            zero[j-1]=1
        array.append(zero)
    for i in array:
        print(*i)

if __name__ == "__main__":
    main()

Python: n = int(input())

g = [[0 for _ in range(n)] for _ in range(n)]

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

for i in range(n):
    print(*g[i])

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]):
    a[b[0]-1][b[i+2]-1]=1
for i in a:
  print(i)

Python: def main():
    num = int(input())
    T = [[0] * num for i in range(num)]
    for n in range(num):
        a = list(map(int,input().split()))
        u = a[0] - 1
        if a[1] > 0:
            for i in a[2:]:
                T[u][i-1] = 1

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

if __name__ == '__main__':
    main()

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

Python: n = int(input())

a = [[0]*n for x in range(n)]

for i in range(n):
  nood = list(map(int,input().split()))
  nood_elements = nood[0]-1
  for j in range(2,len(nood)):
    a[nood_elements][nood[j]-1] += 1
  
  for j in range(n-1):
    print(a[nood_elements][j],end=" ")
  print(a[nood_elements][n-1])

Python: n = int(input())
l = []
tmp = 0 
for _ in range(n):
    a = list(map(int,input().split()))
    l.append(a)
    if a[len(a)-1] > tmp:
        tmp = a[len(a)-1]

ans = [[0 for i in range(tmp)] for j in range(n)]
for i in range(n):
    if l[i][1] > 0:
        for j in range(2,len(l[i])):
            tmp1 = l[i][j]
            ans[i][tmp1-1] = 1

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

Python: # -*- coding: utf-8 -*-
"""
Created on Sun Jul  8 09:32:48 2018

@author: maezawa
"""

n = int(input())
adj = [[] for _ in range(n)]
a  = [[0 for _ in range(n)] for _ in range(n)]

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

Python: # -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

N=INT()
G=[[0]*N for i in range(N)]
for i in range(N):
    l=LIST()
    u=l[0]
    l=l[2:]
    for v in l:
        G[u-1][v-1]=1

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

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

for i in range(n):
  for j in range(n):
    print("%d "%(v[i][j]))

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:
    print(" ".join(map(str, a)))

Python: n = int(input())

results = [[0] * n for i in range(n)]

for i in range(n):
    arr = list(map(int, input().split()))
    for j in range(arr[1]):
        results[i][arr[j+2]-1] = 1

for ret in results:
    for i in range(len(ret)):
        if i == len(ret)-1:
            print(ret[i], end='')
        else:
            print(ret[i], '', end='')
    print('')

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

for i in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:
        for adj in tmp[2:]:
            M[i][adj-1] = 1
    print(*M[i])