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())
Adj = [0 for i in range(n)]

for i in range(n):
    row = list(map(int, input().split(' ')))
    Adj[row[0] - 1] = row

for adj in Adj:
    k = adj[1]
    E = adj[2:2+k]
    row = [0 for i in range(n)]
    for i in E:
        row[i - 1] = 1
    print(' '.join(map(str, row)))

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: import sys


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

    def printAdjMatrix(self):
        n = len(self.nodes)
        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)


n = int(input())
G = Graph()
for line in sys.stdin:
    numList = list(map(int, line.split()))
    G.nodes[numList[0]] = list(numList[2:])

G.printAdjMatrix()

Python: n = int(input())

for i in range(n):
    s = [int(x) for x in input().split()]
    s.reverse()

    u, k = s.pop(), s.pop()
    se = set()
    for j in range(k):
        se.add(s.pop())

    ans = []
    for i in range(1, n + 1):
        ans.append(int(i in se))

    print(*ans)

Python: n = int(input())

l = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(n + 1):
    if i == 0:
        continue
    u = list(map(int, input().split()))
    for x in u[2:]:
        l[i][x] = 1

for i in range(n + 1):
    if i == 0:
        continue
    print(*l[i][1:])

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

for _ in range(absN):
    cmd = list(map(int, input().split(" ")))
    for i in range(cmd[1]):
        M[cmd[0]-1][cmd[i+2]-1] = 1

for x in M:
    x =map(str, x)
    print(" ".join(x))

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

for i in range(n):
    n1, num, *cl = list(map(int, input().split()))
    for n2 in cl:
        ans[n1-1][n2-1] = 1
    print(*ans[i])

Python: n=int(input())

l=[[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:]:
            l[i][j]=1

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

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

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

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = 1

for i in range(n):
    s = ""
    for m in matrices[i]:
        s += str(m) + " "
    print(s)

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

for i in range(n):
   info = [int(x) for x in input().split()]
   for j in info[2:]:
       a[i][j-1]=1

for v in a:
    print(*v)

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

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

Python: n = int(input())
m = [[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:
    m[f][num] = 1

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

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

nodes = []
for i in range(n):
    tmp_nodes = [int(x) for x in  input().split()]

    tmp = 2
    j = 1
    while j <= n:
        if j != 1:
            print(" ", end = "")
        if tmp < len(tmp_nodes) and j == tmp_nodes[tmp]:
            print(1, end = "")
            tmp += 1
        else:
            print(0, end = "")
        j += 1
        

    print("")

Python: #16D8101014F KurumeRyunosuke 2018/6/20
#import numpy as np
n=int(input())
#ls=np.zeros((n,n))
ls=[[0] * n] * 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())

for i in range(n):
    matrix = [str(0)]*n
    a = list(map(int, input().split()))
    if len(a) > 2:
        for j in a[2:]:
            matrix[j-1] = str(1)
    print(' '.join(matrix))

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

for _ in range(N):
    u, n, *K = map(int, input().split())
    u -= 1
    for k in K:
        k -= 1
        G[u][k] = 1

for g in G:
    print(*g)

Python: n=int(input())
v=[]
u=0
e=0

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

for i in range(n):
    S=input().split()
    if S[1]!=0:
        for j in range(int(S[1])):
            A[i][int(S[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: 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(str(matrix)))