Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

Python: n = int(input())

adj_mat = [[0] * (n + 1) for j in range(n)]

for i in range(n):
    adj_list_i = list(map(int, input().split()[2:]))
    for j in adj_list_i:
        adj_mat[i][j] = 1

for r in adj_mat:
    print(*r[1:])

Python: n = int(input())

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

for i in range(n):
    row = [ int(r) for r in input().split()]
    u = row[0] - 1
    if (row[1] > 0):
        for j in range(row[1]):
            v = row[2 + j] - 1
            A[u][v] = 1
            
for i in range(n):
    print(" ".join([str(st) for st in A[i]]))

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

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

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 column_g:
    print(*v)

Python: if __name__ == '__main__':
    N = int(input())
    matrix = [[0] * N for _ in range(N)]
    for i in matrix:
        node_info = [int(i) for i in input().split()]
        node_i = node_info[0] - 1
        if not node_info[1] == 0:
            for i in node_info[2:]:
                matrix[node_i][i-1] = 1
    [print(line) for line in matrix]

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

for i in range(N):
    ls = list(map(int,input().split()))
    u = ls[0] - 1
    for v in ls[2:]:
        G[u][v-1] = 1

for row in G:
    print(' '.join(map(str,row)))

Python: n = int(input())
m = [[0] * n for i in range(n)]
for i in range(n):
    line = [int(v) for v in input().split()]
    u = line[0] - 1
    for v in line[2:]:
        v -= 1
        m[u][v] = 1

for row in m:
    print(' '.join([str(v) for v in row]))

Python: def main():

    n = int(input())
    e = [[0]*n for _ in range(n)]

    for i in range(n):
        m = list(map(int,input().split()))
        for j in range(2,len(m)):
            e[m[0]-1][m[j]-1] = 1

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

if __name__ == '__main__':
    main()

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: # coding: utf-8
N = int(input().rstrip())
A = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    line = [int(i) for i in input().rstrip().split()]
    for j in range(line[1]):
        A[line[0]-1][line[j+2]-1] = 1

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

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

    for i in range(n):
        d = list(map(int, input().split()))
        for j in range(2, len(d)):
            m[d[0]][d[j]] = 1

    for i in range(1, n+1):
        print(" ".join([str(m[i][j]) for j in range(1, len(m[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])
    adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    # assert len(vertex_info) == vertex_num

    ans = generate_graph(vertex_info)
    for v_result in ans:
        print(*v_result)

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 i in range(n)]for j in range(n)]
for i in range(n):
    list=[int(m) for m in input().split()]
    u=list[0]
    k=list[1]
    for j in range(2,len(list)):
        v=list[j]
        G[u-1][v-1]=1
for i in range(n):
    for j in range(n):
        print(G[i][j],end=" ")
    print("")

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

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

    print(*GM[i])

Python: n = int(input())
M = [[0] * n for i in range(n)]
u_k_v = [list(map(int, input().split())) for i in range(n)]

for i in u_k_v:
    u, k, V = i[0] - 1, i[1], i[2:]
    for v in V:
        M[u][v - 1] = 1
 
for i in range(n):
    for j in range(n):
        print(M[i][j], end  = ' ')
    print()

Python: # Graph I - Graph
n = int(input())
for _ in range(n):
    ss = list(map(int, input().split()))
    u = ss[0] - 1
    row = [0 for _ in range(n)]
    for i in range(ss[1]):
        idx = 2 + i
        row[ss[idx]-1] = 1
    print(*row)

Python: n = int(input())

mat = [[0] * (n) for _ in range(n)]

for _ in range(n):
    array = list(map(int, input().split()))
    u = array[0]
    k = array[1]
    for i in range(2, len(array)):
        mat[u - 1][array[i] - 1] = 1
        # mat[array[i] - 1][u - 1] = 1

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

Python: n = int(input())
l = []
pad = 0
for i in range(n):
    m = [0]*n
    s = list(map(int,input().split()))
    if s[1] != 0:
        for j in s[2:]:
            m[j-1] = 1
    
    print(*m)

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 20001;

int G[101][101];

int main(void)
{
	int n, k, v, u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int i = 0; i < k; i++) {
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << G[i][j];
			if (j != n)
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}