Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

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

a=[[0 for i2 in range(n)]for i1 in range(n)]

for i in range(n):
    for j in range(adj[i][1]):
        a[i][adj[i][j+2]-1]=1

    for j in range(n):
        if j ==n-1:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")

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:]:
                print(i)
                T[u][i-1] = 1

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

if __name__ == '__main__':
    main()

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def generate_graph(v_info):
    for info in v_info:
        adj_info = info[2:]
        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: from sys import stdin
n = int(stdin.readline())
v = [[0] * (n + 1) for i in range(n + 1)]
for u in range(1, n + 1):
    U = [int(j) for j in stdin.readline().split()]
    for k in U[2:]:
        v[u][k] += 1
for i in range(1, n + 1):
    print(*v[i][1:])

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

for i in range(n):
    u = list(map(int, input().split()))
    if u[1] > 0:
        for i in u[2: 2 + u[1]]:
            Adj[u[0] - 1][i - 1] = 1

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

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

for _ in range(n):
    lst = list(map(int, input().split()))
    
    x = lst[0] - 1
    
    if lst[1] == 0:
        continue
    
    for y in lst[2:]:
        adj_list[x][y-1] = 1
    
for r in adj_list:
    print(" ".join([ str(v) for v in r]))

Python: #!/usr/bin/python3
n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    u = l[0]
    V = l[2:]
    for v in V:
        A[u - 1][v - 1] = 1
for a in A:
    print(" ".join(map(str, a)))

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):
    print(" ".join(matrices[i]))

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

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

N = int(input())
adj = [["0"]*N for _ in range(N)]

for _ in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = "1"

for a in adj:
    print(" ".join(a))

Python: #!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n=int(input())
G=[[0]*n for i in range(n)]
for i in range(n):
    inp=tuple(map(int,input().split()))
    now=inp[0]
    for j in range(2,inp[1]+2):
        G[now-1][inp[j]-1]=1
for g in G:
    print(*g)

Python: n=int(input())
adj=[list(map(int,input().split())) for _ in range(n)]

lst=[[0 for i in range(n)] for j in range(n)]
for x in adj:
    u,v=x[0],x[2:]
    for y in v:
        lst[u-1][y-1]=1

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

Python: N= int(input())

b=[[0 for i in range(N)]for j in range(N)]


for i in range(N):
    a= list(map(int, input().split()))
    for j in range(a[1]):
        b[i][a[2+j]-1]=1
    
for i in range(N):
    print(*b[i])

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

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

    for j in range(2,len(u)):
        G[i][u[j]-1]=1


G=[' '.join(map(str,G[i])) for i in range(n)]
print('\n'.join(G))

Python: n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l1 = list( [0 for i in range(n)] for _ in range(n))
for i in l:
  a,b,*c = i
  for j in c:
    l1[a-1][j-1] = 1
for k in l1:
  print(*k)

Python: if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for _ in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????????
    graph_table = [[0]*num for _ in range(num)]
    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 row in graph_table:
        print(*row)

Python: n = int(input())

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

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    u = tmp[0]
    k = tmp[1]
    l = tmp[2:]
    for x in l:
        m[u-1][x-1] = 1

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

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

Python: N = int(input())
P = [[0 for _ in range(N)] for _ in range(N)] 
for i in range(N):
    u,k,*varray = map(int,input().split()) # u,k は数, varray は配列
    for v in varray:
        P[u-1][v-1] = 1
for j in P:
    print(" ".join(map(str,j)))

Python: n = int(input())
adj = []
# adj = [[None] * n for _ in range(n)]
ans = [[0] * n for _ in range(n)]

for i in range(n):
    temp = list(map(int, input().split()))
    if len(temp) > 2:
        adj.append(temp[2:])
    else:
        adj.append([])

# print(adj)
# print(ans)

for i in range(n):
    for j in range(len(adj[i])):
        ans[i][adj[i][j]-1] = 1

# print(ans)

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

Python: # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A&lang=jp
# Graph: python3
#  2018.12.04 yonezawa

import sys
input = sys.stdin.readline
#import cProfile
def main():
    n = int(input())
    nmap = [[0 for i in range(n)] for i in range(n)]

    for _ in range(n):
        l = list(map(int,input().split()))
        a = l[0] - 1
        for i in l[2:]:
            nmap[a][i-1] = 1
    for i in nmap:
        print (*i)
        
if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()

Python: 
N = int(input())

# initialize
ans = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
    a = list(map(int, input().split()))
    id = a[0]
    jisu = a[1]
    for j in range(jisu):
        c = a[j+2]
        ans[i][c-1] = 1

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

            if i != N-1: print("")