Go: package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	graph := make([][]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		var u, k int
		fmt.Scan(&u, &k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			v--
			graph[i][v] = 1
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if j > 0 {
				fmt.Print(" ")
			}
			fmt.Print(graph[i][j])
		}
		fmt.Println()
	}
}

Python: import sys

input = sys.stdin.readline
n = int(input())
adj_list = [[0]*n for _ in range(n)]
for _ in range(n):
    input_list = list(map(int, input().split()))
    u = input_list[0] - 1
    e_num = input_list[1]
    if e_num > 0:
        for i in range(e_num):
            adj_list[u][input_list[i+2] - 1] = 1

for adj in adj_list:
    print(' '.join(map(str, adj)))

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

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

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

#print(arr)

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])
            #print(x,y,z)
            arr[x-1][z-1]=1
            #print(arr)
            d=d+1

print(arr)

Python: import sys

n = int(sys.stdin.readline())

for i in range(n):
    aa = list(map(int, sys.stdin.readline().split()))
    c = [0] * n
    for j in aa[2:]:
        c[j-1]=1
    print(' '.join(map(str,c)))

Python: n = int(input())
main = [[0] * (n+1) for i in range(n+1)]

for i in range(n):
	a = input().split()
	for j in range(int(a[1])):
		main[int(a[0])][int(a[j+2])] = 1

#print(main)
for i in range(1,n+1):
	print(*main[i][1:])

del a