Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

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;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int judge(int i, int n, int variable, vector< vector<int> > &v)
{
	for (int j = 0; j<v[variable].size(); ++j) {
		if (i == v[variable][j]) {
			return 1;
			break;
		}
	}
	return 0;
}
int main()
{
	int n, u, k, vv;
	cin >> n;
	vector< vector<int> > v(n), a(n, vector<int>(n));
	for (int variable = 0; variable<n; ++variable) {
		cin >> u >> k;
		for (int i = 0; i<k; ++i) {
			cin >> vv;
			v[variable].push_back(vv);
		}
	}
	for (int variable = 0; variable<n; ++variable)
		for (int i = 1; i <= n; ++i)
			a[variable][i - 1] = judge(i, n, variable, v);
	for (int variable = 0; variable<n; ++variable)
		for (int i = 0; i<n; ++i)
			printf("%d%c", a[variable][i], i == n - 1 ? "\n" : " ");
}

C++: 
#include <iostream>
using namespace std;
int main() {
    int n,p,q,x;
    cin>>n;
    int A[100][100]={0};
    for (int i=0;i<n;i++){
        cin>>q>>p;
        if (p==0)
            continue;
        for (int j=0;j<p;j++){
            cin>>x;
            A[q][x-1]=1;
        }
    }
    
    
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            cout<<A[i][j];
            if (j!=n-1)cout<<" "; 
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int main ()
{
    int N;
    cin >> N;

    int M[N][N];

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << " " << M[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#define MAX 120
using namespace std;

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    int graph[MAX][MAX];
    cin >> n;

    // init
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            graph[i][j] = 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            graph[u - 1][v - 1] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << graph[i][j];
            if (j != n) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n; j++)
	{
	  if (ln[i][j] != 0 )
	    {
	      m[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j] << " ";
	}
      cout << endl;
    }
  return 0;
}